i have problem ruby on rails web app.
i have model class called source, , in routes.rb, add following configuration:
namespace :admins resources :sources collection 'batch_new' post 'batch_create' end end end
when run rake routes
, can see:
admins_source /admins/sources/:id(.:format) admins/sources#show put /admins/sources/:id(.:format) admins/sources#update delete /admins/sources/:id(.:format) admins/sources#destroy
but when send these requests via clicking link or form submitting, 404.
here code in views/admins/sources/_form.html.erb
<%= form_for [:admins, @source] |f| %> <% if @source.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@source.errors.count, "error") %> prohibited source being saved:</h2> <ul> <% @source.errors.full_messages.each |msg| %> <li><%= msg %></li> <% end %> </ul> </div> <% end %> <div class="field"> <%= f.label :name %> <%= f.text_field :name %> </div> <div class="field"> <%= f.label :url %> <%= f.text_field :url %> </div> <div class="actions"> <%= f.submit %> </div> <% end %>
here code of destroy link on views/admins/sources/index.html.erb:
<%= link_to 'destroy', admins_source_url(source), method: :delete, data: { confirm: 'are sure?' } %>
and here code in sourcescontroller
def destroy @source = source.find(params[:id]) @source.destroy respond_to |format| format.html { redirect_to admins_sources_url } format.json { head :no_content } end end
this problem occurs in production environment. development environment fine.
i did asset precompiling production env before starting server(unicorn). i've no idea how fix issue.
here's environment:
os: ubuntu linux 12.04 lts
ruby version: 2.0.0-p0
rails version: 3.2.13
rails server: unicorn 4.6.2
database production: mysql
database development: sqlite3
you error because have other error (like migration problem, or uncompiled asset). in production logs find real error, posted here should work (if had 1k points not ask this, sorry if did check logs :) )
Comments
Post a Comment