使用路由命名空间和属性的Rails form_for

时间:2018-04-13 09:36:53

标签: ruby-on-rails forms routes helpers

我使用form_for helper和Rails 5使用路由命名空间功能,并将其作为模型名称的别名。

我的路线:

      edit_customer_profile GET    /customer/profile/edit(.:format)                                           customer/profiles#edit
           customer_profile PATCH  /customer/profile(.:format)                                                customer/profiles#update
                            PUT    /customer/profile(.:format)                                                customer/profiles#update

我的观点:

... omit verbosity ...
<%= form_for [:customer, current_user], as: :profile do |f| %>
... omit verbosity ...

我的错误:

undefined method `customer_user_path' for #<#<Class:0x007f0f8d0ddce0>:0x00558c965b4a78>

使用手中的文档时,表单助手必须使用customer_profile_path而不是customer_user_path

1 个答案:

答案 0 :(得分:0)

使用private void setupRecyclerView() { if(shouldStartSignIn()) return; if(!PermissionUtils.requestPermission(this, RC_STORAGE_PERMISSION, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) { Log.e(TAG, "Permission not granted, don't continue"); return; } LinearLayoutManager layoutManager = new LinearLayoutManager(this); pagesRecyclerView.setLayoutManager(layoutManager); Query query = FirebaseFirestore.getInstance().collection(Page.COLLECTION).whereEqualTo(Page.FIELD_USER_ID, FirebaseAuth.getInstance().getCurrentUser().getUid()).orderBy(Page.FIELD_TIMESTAMP).limit(50); FirestoreRecyclerOptions<Page> options = new FirestoreRecyclerOptions.Builder<Page>().setQuery(query, Page.class).build(); adapter = new PagesAdapter(options, this); pagesRecyclerView.setAdapter(adapter); }