Это мой маршрут:
scope ":username" do
resources :feedbacks
end
Когда я делаю rake routes
, я получаю это:
feedbacks GET /:username/feedbacks(.:format) {:action=>"index", :controller=>"feedbacks"}
POST /:username/feedbacks(.:format) {:action=>"create", :controller=>"feedbacks"}
new_feedback GET /:username/feedbacks/new(.:format) {:action=>"new", :controller=>"feedbacks"}
edit_feedback GET /:username/feedbacks/:id/edit(.:format) {:action=>"edit", :controller=>"feedbacks"}
feedback GET /:username/feedbacks/:id(.:format) {:action=>"show", :controller=>"feedbacks"}
PUT /:username/feedbacks/:id(.:format) {:action=>"update", :controller=>"feedbacks"}
DELETE /:username/feedbacks/:id(.:format) {:action=>"destroy", :controller=>"feedbacks"}
Но когда я делаю feedbacks_url или feedbacks_path, я получаю ошибку маршрутизации, такую какэто:
No route matches {:controller=>"feedbacks", :format=>nil}
Из файла журнала:
Rendered users/show.html.erb within layouts/application (18.3ms)
Completed 500 Internal Server Error in 142ms
ActionView::Template::Error (No route matches {:controller=>"feedbacks", :format=>nil}):
1: <%= form_for(@feedback) do |f| %>
2: <% if @feedback.errors.any? %>
3: <div id="error_explanation">
4: <h2><%= pluralize(@feedback.errors.count, "error") %> prohibited this feedback from being saved:</h2>
app/views/feedbacks/_form.html.erb:1:in `_app_views_feedbacks__form_html_erb__2195884682603870163_2484875900'
app/views/users/show.html.erb:11:in `_app_views_users_show_html_erb__3889159515317937411_2159438040'
app/controllers/vanities_controller.rb:14:in `show'
Это частичная форма feedbacks/_form.html.erb
:
<%= form_for(@feedback) do |f| %>
<% if @feedback.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@feedback.errors.count, "error") %> prohibited this feedback from being saved:</h2>
<ul>
<% @feedback.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<% if current_user %>
<div class="poster_id">
<%= f.hidden_field "poster_id", :value => current_user.id %><br />
</div>
<div class="receiver_id">
<%= f.hidden_field "receiver_id", :value => @user.id %><br />
</div>
<div class="field">
<%= f.text_field :content %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
<% end %>
Мысли?