Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange Routing error in rails 3.2
    primarykey
    data
    text
    <p>I am implementing an application in which i want to change the settings of the application. While doing so I am getting an error</p> <pre><code>no routes matches {:action=&gt;"show", :controller=&gt;"settings", format=&gt;"nil"} </code></pre> <p>while clicking on the open <code>new settings</code> tab.</p> <p>my <code>index.html</code> is as follows:-</p> <pre><code>&lt;h1&gt;Listing settings&lt;/h1&gt; &lt;table class="table table-striped table-bordered"&gt; &lt;tr&gt; &lt;th&gt;ID&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Value&lt;/th&gt; &lt;th&gt;Description&lt;/th&gt; &lt;th&gt;Edit&lt;/th&gt; &lt;th&gt;Delete&lt;/th&gt; &lt;/tr&gt; &lt;% @settings.each do |c| %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= c.id %&gt; &amp;nbsp;&lt;/td&gt; &lt;td&gt;&lt;%= c.name %&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&lt;%= c.value %&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&lt;%= c.description %&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&lt;%= link_to 'Edit', {:action =&gt; 'edit', :id =&gt; c.id} %&gt; &amp;nbsp;&lt;/td&gt; &lt;td&gt;&lt;%= link_to 'Delete', {:action =&gt; 'delete', :id =&gt; c.id}, :data =&gt; { :confirm =&gt; "Are you sure you want to delete this value?" } %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;% end %&gt; &lt;/table&gt; &lt;br /&gt; &lt;%= link_to 'New Setting', {:action =&gt; 'new'} %&gt; </code></pre> <p>My <code>settings controller</code> is as follows:-</p> <pre><code>class SettingsController &lt; ApplicationController # GET /setting # GET /setting.json def index @settings = Setting.all respond_to do |format| format.html # index.html.erb format.json { render json: @settings } end end # GET /setting/1 # GET /setting/1.json def show @setting = Setting.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @setting } end end # GET /setting/new # GET /setting/new.json def new @setting = Setting.new respond_to do |format| format.html # new.html.erb format.json { render json: @setting } end end # GET /setting/1/edit def edit @setting = Setting.find(params[:id]) end # POST /setting # POST /setting.json def create @setting = Setting.new(params[:setting]) respond_to do |format| if @setting.save format.html { redirect_to @setting, notice: 'Setting was successfully created.' } format.json { render json: @setting, status: :created, location: @setting } else format.html { render action: "new" } format.json { render json: @setting.errors, status: :unprocessable_entity } end end end # PUT /setting/1 # PUT /setting/1.json def update @setting = Setting.find(params[:id]) respond_to do |format| if @setting.update_attributes(params[:setting]) format.html { redirect_to @setting, notice: 'Setting was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @setting.errors, status: :unprocessable_entity } end end end # DELETE /setting/1 # DELETE /setting/1.json def delete @setting = Setting.find(params[:id]) @setting.deleted = 1 @setting.save respond_to do |format| format.html { redirect_to settings_url } format.json { render :json =&gt; { :success =&gt; true } } end end end </code></pre> <p>My <code>new.html</code> is as follows:-</p> <pre><code>&lt;h1&gt;New settings&lt;/h1&gt; &lt;%= form_for @setting do |f| %&gt; &lt;% if @setting.errors.any? %&gt; &lt;div id="errorExplanation"&gt; &lt;h2&gt;&lt;%= pluralize(@setting.errors.count, "error") %&gt; prohibited this setting from being saved:&lt;/h2&gt; &lt;ul&gt; &lt;% @setting.errors.full_messages.each do |msg| %&gt; &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt; &lt;% end %&gt; &lt;/ul&gt; &lt;/div&gt; &lt;% end %&gt; Id: &lt;%= f.text_field :id %&gt;&lt;br&gt; Name: &lt;%= f.text_field :name %&gt;&lt;br&gt; Values: &lt;%= f.text_field :value %&gt;&lt;br&gt; Description: &lt;%= f.text_field :description %&gt;&lt;br&gt; &lt;% end %&gt; &lt;%= link_to 'Back', settings_path %&gt; </code></pre> <p>My routes.rb is as follows:-</p> <pre><code> Lms::Application.routes.draw do resources :books do member do post 'add' post 'remove' end collection do get 'add' get 'list' =&gt; "books#index" post 'get_books' get 'get_books' end end resources :books resources :book_transactions resources :book_issues resources :book_holds resources :categories resources :users resources :admins resources :library_locations resources :lov_values resources :loan_fines resources :lov_names resources :loans_fines do member do post 'add' post 'remove' end collection do get 'add' get 'list' post 'get_loans_fines' get 'get_loans_fines' end end resources :settings do member do post 'add' post 'remove' end collection do get 'add' get 'list' post 'get_settings' get 'get_settings' end end root :to =&gt; 'books#index' match ':controller(/:action(/:id))(.:format)' </code></pre> <p>The strange part is that when i click on <code>new</code> action it is going/redirecting to the <code>show</code> action..I am a bit confused why this is happening..</p> <p>Can some one help me with this..</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload