我有一个rails应用程序,我最近推送到'生产'VPS托管服务器。我使用Capistrano进行部署,它似乎已经很好地服务于服务器了。我更改了应用程序的当前目录并运行了bundle install以开始设置所有内容并点击此错误:
public class NavigationDrawerFragment extends Fragment implements GookAdapter.ClickListener {
private GookAdapter adapter;
private RecyclerView recyclerView;
public static final String PREF_FILE_NAME="testpref";
public static final String KEY_USER_LEARNED_DRAWER="user_learned_drawer";
private ActionBarDrawerToggle mDrawerToggle;
private DrawerLayout mDrawerLayout;
private boolean mUserLearnedDrawer;
private boolean mFromSavedInstanceState;
private View containerView;
public NavigationDrawerFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mUserLearnedDrawer = Boolean.valueOf(readFromPreference(getActivity(), KEY_USER_LEARNED_DRAWER,"false"));
if(savedInstanceState!=null){
mFromSavedInstanceState=true;
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View layout = inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
recyclerView= (RecyclerView) layout.findViewById(R.id.drawerList);
adapter = new GookAdapter(getActivity(), getData());
adapter.setOnClickListener(this);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
return layout;
}
public static List<Information> getData(){
List<Information> data = new ArrayList<>();
int[] icons = {R.drawable.home,
R.drawable.reminder,
R.drawable.importdata,
R.drawable.exportdata,
R.drawable.settings};
String [] titles = {"New Transaction", "Reminder", "Import Data", "Export Data", "Category Setting"};
for (int i=0;i<titles.length && i<icons.length;i++){
Information current = new Information();
current.iconId=icons[i%icons.length];
current.title=titles[i%titles.length];
data.add(current);
}
return data;
}
public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbar toolbar) {
containerView=getActivity().findViewById(fragmentId);
mDrawerLayout = drawerLayout;
mDrawerToggle= new ActionBarDrawerToggle(getActivity(), drawerLayout, toolbar, R.string.drawerOpen, R.string.drawerClose){
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if(!mUserLearnedDrawer){
mUserLearnedDrawer=true;
savedToPreferences(getActivity(), KEY_USER_LEARNED_DRAWER, mUserLearnedDrawer+"");
}
getActivity().invalidateOptionsMenu();
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
getActivity().invalidateOptionsMenu();
}
};
if(!mUserLearnedDrawer && !mFromSavedInstanceState){
mDrawerLayout.openDrawer(containerView);
}
mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerLayout.post(new Runnable() {
@Override
public void run() {
mDrawerToggle.syncState();
}
});
}
public static void savedToPreferences(Context context, String preferenceName, String preferenceValue){
SharedPreferences sharedPreferences = context.getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(preferenceName, preferenceValue);
editor.apply();
}
public static String readFromPreference(Context context, String preferenceName, String defaultValue){
SharedPreferences sharedPreferences = context.getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE);
return sharedPreferences.getString(preferenceName, defaultValue);
}
@Override
public void itemClicked(View view, int position) {
if(position == 0){
startActivity(new Intent(getActivity(), NewTransaction.class));
getActivity().finish();
}else if(position == 1){
startActivity(new Intent(getActivity(), Reminder.class));
getActivity().finish();
}else if(position == 2){
startActivity(new Intent(getActivity(), Reminder.class));
getActivity().finish();
}else if(position == 3){
startActivity(new Intent(getActivity(), Reminder.class));
getActivity().finish();
}else{
startActivity(new Intent(getActivity(), CategorySetting.class));
}
}
我不熟悉这个错误,对我来说这是一个未知的领域,所以我有点失落。我能够在服务器soure code
上获得postgres我很确定这是一个简单的解决方案,我只是不熟悉设置新服务器,所以我不确定我在这里做什么!
编辑:
如下所示,我将lib和dev包添加到我的服务器。我在Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20151105-8574-y7clqw.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
找到了pg_conf,但我的应用程序似乎无法找到它,导致上面的错误。当我按照上面的错误输出中的建议尝试执行/usr/pgsql-9.3/bin
时,我收到$ bundle install --with-pg-config=/usr/pgsql-9.3/bin
错误。
我应该如何映射到文件?还有其他事情发生在这里,我不理解吗?
答案 0 :(得分:0)
ssh到您的生产机器并在该机器上安装postgresql-devel
包,这将解决pg_config missing
的问题:
sudo apt-get install libpq-dev