Namespace - new =) edit =(

24 views
Skip to first unread message

Lucas Lima de Souza

unread,
Aug 14, 2012, 9:39:18 AM8/14/12
to plataformate...@googlegroups.com
Hello!!! I'm using namespace:

  namespace :freelances do
    resource :profiles
  end

When I use freelance/profiles/new the form works normally:

<%=simple_form_for [:freelances,@profile] do |f| %>
 <%=f.input :name %>
 <%=f.input :phone %>
 <%=f.input :cell_phone %>
 <%=f.input :experience, :as => :text, :input_html => { :rows => 4 } %>
 <%=f.association :categories,:as => :check_boxes %>
 <%=f.submit %><br/>
 <%end%>

But when I want to edit some profile it's not works

undefined method `freelances_profile_path' for #<#<Class:0xa08613c>:0xa90ccc0>

Extracted source (around line #1):

1: <%=simple_form_for [:freelances,@profile] do |f| %>
2:  <%=f.input :name %>
3:  <%=f.input :phone %>
4:  <%=f.input :cell_phone %>

Carlos Antonio da Silva

unread,
Aug 14, 2012, 10:05:04 AM8/14/12
to plataformate...@googlegroups.com
Check your rake routes, you're gonna see that the url does not exist. Technically, forms are not aware of a singleton `resource`, so it tries to use the default url for resources instead. In such cases, you usually have to give the full :url option to the form. It happens to work for the new route because there's no difference between them for resource and resources, but the edit action does have (resources have the id).

Note: this is how Rails handles forms and urls, not a specific SimpleForm functionality.
--
At.
Carlos Antonio

Lucas Lima de Souza

unread,
Aug 14, 2012, 10:17:24 AM8/14/12
to plataformate...@googlegroups.com
Thank you, Carlos!!! It's works normally.

=D
Reply all
Reply to author
Forward
0 new messages