How do I get this page to paginate using kaminari? I need help with this badly. I don't know what to do. Just get me some way so that all the posts will only be 15 per page. I want the show page to be paginated not the index page.
This is the website I built.
http://duelingpets.net/maintopics/9/subtopics/4
This is my show page for my subtopics page that is nested under maintopics
<p id="notice"><%= notice %></p>
This pages shows the current topic name of a subtopic
<h1 class="forumheader"><%= #subtopic.topicname %></h1>
<br><!---Gives space to start the narratives--->
<div class="narrativecontainer">
<table>
<tr>
<td><%= #subtopic.topicname %></td>
</tr>
<tr>
<td>by: <%= #subtopic.user.vname %></td>
</tr>
<tr>
<td><pre class="narrative_pre"><%= #subtopic.description %></pre></td>
</tr>
</table>
<br>
<% #subtopic.narratives.each do |narrative| %>
<div class="outer">
<table>
<tr>
<td>re:<%= narrative.subtopic.topicname %></td>
<% if current_user && (current_user.id == narrative.user_id || current_user.admin?)%>
<td><%= button_to 'Edit', edit_subtopic_narrative_path(#subtopic, narrative), method: :get %></td>
<td><%= button_to 'Destroy', [#subtopic, narrative], method: :delete, data: { confirm: 'Are you sure?' } %></td>
<% end %>
</tr>
<tr>
<td>by: <%= narrative.user.vname %><%#= subtopic.description %></td>
</tr>
</table>
</div>
<div class="outer">
<pre class="narrative_pre"><%= narrative.story %></pre>
</div>
<br>
<% end %>
</div>
<br>
<% if current_user %>
<p><%= link_to 'New Narrative', new_subtopic_narrative_path(#subtopic) %></p>
<br>
<% end %>
<p><%= link_to 'Back', tcontainer_maintopic_path(#maintopic.tcontainer_id, #maintopic) %></p>
This my subtopics controller.
class SubtopicsController < ApplicationController
# GET /subtopics
# GET /subtopics.json
#before_filter :load_forum
before_filter :load_topic, :only => [:edit, :update, :show, :destroy]
before_filter :load_maintopic, :only =>[:create, :index, :new]
def index
if current_user && current_user.admin?
#subtopics = #maintopic.subtopics.all
else
render "public/404"
end
end
# GET /subtopics/1
# GET /subtopics/1.json
def show
##subtopic.narratives.page(params[:page])
respond_to do |format|
format.html # show.html.erb
format.json { render json: #subtopic }
end
end
# GET /subtopics/new
# GET /subtopics/new.json
def new
if current_user
#user = current_user.id
#subtopic = #maintopic.subtopics.build
#subtopic.user_id = #user
else
redirect_to root_url
end
end
# GET /subtopics/1/edit
def edit
end
# POST /subtopics
# POST /subtopics.json
def create
if current_user
#user = current_user.id
#subtopic = #maintopic.subtopics.new(params[:subtopic])
#subtopic.user_id = #user
if !(#subtopic.maintopic_id == #maintopic.id) #Prevents a subtopic from being assigned data to a maintopic that doesn't match
redirect_to #maintopic
return
end
#subtopic.created_on = Time.now
#subtopic.save
#if #subtopic.save
# redirect_to #maintopic.subtopic
#else
# render "new";
#end
redirect_to maintopic_subtopic_path(#maintopic, #subtopic)
else
redirect_to root_url
end
end
# PUT /subtopics/1
# PUT /subtopics/1.json
def update
respond_to do |format|
if #subtopic.update_attributes(params[:subtopic])
format.html { redirect_to maintopic_subtopic_path(#subtopic.maintopic_id, #subtopic.id), notice: 'Subtopic was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: #subtopic.errors, status: :unprocessable_entity }
end
end
end
#raise
# DELETE /subtopics/1
# DELETE /subtopics/1.json
def destroy
#subtopic.destroy
respond_to do |format|
format.html { redirect_to tcontainer_maintopic_path(#maintopic.tcontainer_id, #maintopic.id) }
format.json { head :no_content }
end
end
private
def load_topic
#subtopic = Subtopic.find(params[:id])
#maintopic = Maintopic.find(#subtopic.maintopic_id)
#content = Maintopic.find(params[:maintopic_id])
if #content.id != #maintopic.id
# raise "I been tampered with and should redirect to the root page"
redirect_to root_url
end
end
def load_maintopic
#maintopic = Maintopic.find(params[:maintopic_id])
end
end
in the Subtopic model add the string:
paginates_per 15
in the controller:
def index
if current_user && current_user.admin?
#subtopics = #maintopic.subtopics.page params[:page]
else
render "public/404"
end
end
and in the index view add:
<%= paginate #subtopics %>
For more information about formatting paginator go to https://github.com/amatsuda/kaminari#helpers
try this in your controller index
`#subtopics = kaminari.paginate_array(#subtopics).page(params[:page]).per(params[:per_page])`
and in your views, edit as
<%= page_entries_info #subtopics %> and also <%= paginate #subtopics, :theme => 'twitter-bootstrap-3' %>
Related
I have a list of movie categories displayed on my home page. Along with this, I have displayed the list of ALL the movies currently available in the db. When the user clicks on one of the categories, I would like to re-render the containing the list of ALL movies to show ONLY the list of movies that belong to the category that the user selected.
I use link_to to display the list of categories. The link_to would be routed to a controller function which loads the movies that belong Only to the category selected by the user. Then a js.erb would be invoked with this generated list which would in-turn invoke a Rails partial.
The Rails partial would re-render the complete movie list to display ONLY the movies that belong to the selected category. The javascript and partial are getting invoked all right but the partial fails to re-render the list. Am not sure what I'm missing here.
app/views/movies/index.html.erb
<% #categories.each do |category| %>
<tr><td>
<%= link_to category, show_category_url(:genre => category), :remote => true %> <%end%>
<%if false %>
<%= link_to show_category_url, :remote => true do %>
category
<%end %>
</td></tr>
<% end %>
<div id="#movies_list">
<% #movies.each do |movie| %>
<tr>
<td><%= movie.title %></td>
<td><%= movie.category %> </td>
<td><%= movie.rating %></td>
<% if !current_user.nil? %>
<% if movie.user.email == current_user.email %>
<td><%= link_to 'Show', movie, :class => "btn btn-primary"%></td>
<td><%= link_to 'Edit', edit_movie_path(movie), :class => "btn btn-primary" %></td>
<td><%= link_to 'Destroy', movie, method: :delete, data: { confirm: 'Are you sure?' }, :class => "btn btn-primary" %></td>
<% end %>
<% end %>
</tr>
<% end %>
</div>
app/views/movies/show.js.erb
$("#movies_list").html("<%= escape_javascript(render("show_category")) %>");
app/views/movies/_show_categories.html.erb
<% #movies_in_category.each do |movie| %>
<tr>
<td><%= movie.title %></td>
<td><%= movie.rating %></td>
<% puts "************** movies/show_category"%>
<% puts movie.title %>
<% if false %>
<td>
<%= form_for #rating do |rating_form| %>
<%= rating_form.number_field :rating, class: 'rating', 'data-size' => 'xs'%>
<%= rating_form.submit 'Add', class: 'btn btn-primary btn-success' %>
<% end %>
</td>
<% end %>
<% if !current_user.nil? %>
<% if movie.user.email == current_user.email %>
<td><%= link_to 'Show', movie, :class => "btn btn-primary"%></td>
<td><%= link_to 'Edit', edit_movie_path(movie), :class => "btn btn-primary" %></td>
<td><%= link_to 'Destroy', movie, method: :delete, data: { confirm: 'Are you sure?' }, :class => "btn btn-primary" %></td>
<% end %>
<% end %>
</tr>
<% end%>
My partial is getting invoked all right but the re-rendering of div movies_list does not happen.
This is my controller code:
class MoviesController < ApplicationController
before_action :set_movie, only: [:show, :edit, :update, :destroy]
#before_action :authenticate_user!
# GET /movies
# GET /movies.json
def index
#movies = Movie.all
$all_movies = #movies
#categories = #movies.uniq.pluck(:category)
#movies_by_category = Hash.new
#categories.each do |category|
#movies_by_category[category] = Movie.where(:category => category).length
end
end
# GET /movies/1
# GET /movies/1.json
def show
respond_to do |format|
format.js {render layout: false}
puts "############## moviescontroller/show_category"
end
end
# GET /movies/new
def new
#movie = current_user.movies.new
end
# GET /movies/1/edit
def edit
end
# POST /movies
# POST /movies.json
def create
#movie = current_user.movies.new(movie_params)
respond_to do |format|
if #movie.save
format.html { redirect_to #movie, notice: 'Movie was successfully created.' }
format.json { render :show, status: :created, location: #movie }
else
format.html { render :new }
format.json { render json: #movie.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /movies/1
# PATCH/PUT /movies/1.json
def update
respond_to do |format|
if #movie.update(movie_params)
format.html { redirect_to #movie, notice: 'Movie was successfully updated.' }
format.json { render :show, status: :ok, location: #movie }
else
format.html { render :edit }
format.json { render json: #movie.errors, status: :unprocessable_entity }
end
end
end
# DELETE /movies/1
# DELETE /movies/1.json
def destroy
#movie.destroy
respond_to do |format|
format.html { redirect_to movies_url, notice: 'Movie was successfully destroyed.' }
format.json { head :no_content }
end
end
def show_category
category_selected = params[:genre]
#all_movies = Movie.all
#movies_in_category = Movie.where(category: category_selected)
puts "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
puts category_selected
puts #movies_in_category.length
end
def login
end
private
# Use callbacks to share common setup or constraints between actions.
def set_movie
#movie = Movie.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def movie_params
params.require(:movie).permit(:title, :category, :rating)
end
end
The reason is,
<div id="#movies_list">
contents goes here..
</div>
You shouldn't add # when defining id attribute for an element, That will be used when selecting an HTML element based on the selector. So remove #
<div id="movies_list">
contents goes here..
</div>
The full text of the error message is:
ActiveRecord::RecordNotFound in TodosController#index
Couldn't find User with id=2
Rails.root: /home/randy/rubystack-1.9.3-29/projects/chap14
app/controllers/application_controller.rb:11:in current_user
app/views/todos/index.html.erb:21:in _app_views_todos_index_html_erb___949818655437808348_39324440
app/controllers/todos_controller.rb:8:in index
Here's the code for my application_controller.rb:
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user
private
def current_user
if session[:user_id]
#current_user ||= User.find(session[:user_id])
else
#current_user = nil
end
end
def check_login
unless authorized?
redirect_to "/auth/identity"
end
end
def logged_in?
if session[:user_id]
return true
else
return false
end
end
protected
def authorized?
logged_in? && (request.get? || current_user.admin?)
end
end."
And here's my todos_controller.rb:
class TodosController < ApplicationController
before_filter :check_login
# GET /todos
# GET /todos.json
def index
#todos = Todo.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: #todos }
end
end
# GET /todos/1
# GET /todos/1.json
def show
#todo = Todo.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: #todo }
end
end
# GET /todos/new
# GET /todos/new.json
def new
#todo = Todo.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: #todo }
end
end
# GET /todos/1/edit
def edit
#todo = Todo.find(params[:id])
end
# POST /todos
# POST /todos.json
def create
#todo = Todo.new(params[:todo])
respond_to do |format|
if #todo.save
format.html { redirect_to #todo, notice: 'Todo was successfully created.' }
format.json { render json: #todo, status: :created, location: #todo }
else
format.html { render action: "new" }
format.json { render json: #todo.errors, status: :unprocessable_entity }
end
end
end
# PUT /todos/1
# PUT /todos/1.json
def update
#todo = Todo.find(params[:id])
respond_to do |format|
if #todo.update_attributes(params[:todo])
format.html { redirect_to #todo, notice: 'Todo was successfully updated.' }
format.json { head :no_content }
#todo = Todo.find(params[:id])
if #todo.completed == true
#todo.user_who_completed = current_user.email
#todo.save
end
else
format.html { render action: "edit" }
format.json { render json: #todo.errors, status: :unprocessable_entity }
end
end
end
# DELETE /todos/1
# DELETE /todos/1.json
def destroy
#todo = Todo.find(params[:id])
#todo.destroy
respond_to do |format|
format.html { redirect_to todos_url }
format.json { head :no_content }
end
end
end."
And my app/views/todos/index.html.erb file:
"<h1>Listing todos</h1>
<table>
<tr>
<th>Name</th>
<th>Completed</th>
<th>Completed date</th>
<th>User</th>
<th></th>
<th></th>
<th></th>
</tr>
<% for todo in #todos %>
<tr>
<td><%= todo.name %></td>
<td><%= todo.completed %></td>
<td><%= todo.completed_date %></td>
<td><%= todo.user %></td>
<% end %>
<% if current_user.admin? %>
<td><%= link_to 'Show', todo %></td>
<td><%= link_to 'Edit', edit_todo_path(todo) %></td>
<td><%= link_to 'Destroy', todo, method: :delete, data: { confirm: 'Are you sure?' } %></td>S
</tr>
<% end %>
</table>
<br />
<% if current_user.admin? %>
<%= link_to 'New Todo', new_todo_path %>
<% end %>
I'm new to rails and have no clue about what the error message means, nor its cause. I want the visitor to land on the todos/index.html page. I have my root route set accordingly. Would appreciate some help.
That error is coming from User.find. It's described in the Documentation for find.
It's telling you that there is no User that has that id. Somehow you have saved a user id into your session that corresponds to a user that doesn't currently exist.
You should probably examine how you are storing user ids to the session and under what circumstances that user could be getting deleted.
The problem is with your loop. If conditional it is outside the cycle.
Check solution view:
<h1>Listing todos</h1>
<table>
<tr>
<th>Name</th>
<th>Completed</th>
<th>Completed date</th>
<th>User</th>
<th></th>
<th></th>
<th></th>
</tr>
<% for todo in #todos %>
<tr>
<td><%= todo.name %></td>
<td><%= todo.completed %></td>
<td><%= todo.completed_date %></td>
<td><%= todo.user %></td>
<% if current_user.admin? %>
<td><%= link_to 'Show', todo %></td>
<td><%= link_to 'Edit', edit_todo_path(todo) %></td>
<td><%= link_to 'Destroy', todo, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<% end %>
</tr>
<% end %>
</table>
Recommendations
Check your question. You have the code view with the controller code.
Be careful with indentation.
I tried to use Ajax request for creating a new object and this had been working very well. In my view file I used to set remote: true option for link_to and everything was fine.
Now I want to render my _form partial once the view file is loaded without a link, but just using a <%= render 'form' %>.
I don't understand why I am getting this error. Who can enlighten me what am I doing wrong?
views/tasks/index.html
<h3>Tasks database</h3>
<table>
<% #tasks.each do |task| %>
<tr class='tasks' id="task_<%= task.id %>">
<td>
<%= link_to user_task_path(current_user, task.id), method: :delete,
data: { confirm: 'Are you sure?' }, remote: true do %>
<i class="glyphicon glyphicon-trash"></i>
<% end %>
<a href="#" data-xeditable="true" data-pk="task" data-model='task' data-name='title'
data-url="/users/<%= current_user.id %>/tasks/<%= task.id %>" data-title="Enter title">
<i><%= task.title %></i>
</a>
</td>
</tr>
<% end %>
<tr>
<td><%= render 'form' %></td>
</tr>
</table>
controllers/tasks_controller.rb
class TasksController < ApplicationController
before_filter :authorize, only: [:edit, :new, :destroy]
def index
#tasks = current_user.tasks
end
def show
#task = Task.find(params[:id])
redirect_to users_path
end
def edit
#task = Task.find(params[:id])
end
def new
#task = Task.new
end
def create
#task = current_user.tasks.new(task_params)
respond_to do |format|
if #task.save
format.html { redirect_to user_tasks_path(current_user) }
format.js
else
format.html { render action: 'new' }
format.js
end
end
end
def update
#task = Task.find(params[:id])
respond_to do |format|
if #task.update(task_params)
format.html { redirect_to user_tasks_path(current_user), notice: 'Post successfully was updated.'}
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { head :no_content }
end
end
end
def destroy
#task = Task.find(params[:id])
#task.destroy
respond_to {|format| format.js }
end
private
def task_params
params.require(:task).permit(:title)
end
end
views/tasks/_form.html
<%= form_for [current_user, #task], remote: true do |f| %>
<%= f.text_field :title %>
<%= f.hidden_field :user_id, value: params[:user_id] %>
<%= f.submit %>
<% end %>
views/tasks/create.js
$('#new_task').remove();
$('#new_link').show();
$('.tasks').last().after("<%=j render partial: 'task', :locals => { :task => #task } %>");
setXeditable();
Here is my rake routes
Any help?
First argument in form cannot contain nil or be empty
You are rendering form in index page and you didn't set #task in index method.
You should set #task in index method
def index
#tasks = current_user.tasks
#task = Task.new
end
This my first ruby on rails application.
Model Location and Post, Location has many post.I create location as tree structure with ancestry gem.
class Post < ActiveRecord::Base
belongs_to :location, :counter_cache => true
end
class Location < ActiveRecord::Base
include Tree
has_ancestry :cache_depth => true
has_many :posts
end
This my Post Controller
class PostsController < ApplicationController
before_action :set_post, only: [:show, :edit, :update, :destroy]
def index
#posts = Post.all
end
def show
end
def new
#post = Post.new
end
def edit
end
def create
#post = Post.new(post_params)
respond_to do |format|
if #post.save
format.html { redirect_to #post, notice: 'Post was successfully created.' }
format.json { render action: 'show', status: :created, location: #post }
else
format.html { render action: 'new' }
format.json { render json: #post.errors, status: :unprocessable_entity }
end
end
end
def update
respond_to do |format|
if #post.update(post_params)
format.html { redirect_to #post, notice: 'Post was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: #post.errors, status: :unprocessable_entity }
end
end
end
def destroy
#post.destroy
respond_to do |format|
format.html { redirect_to posts_url }
format.json { head :no_content }
end
end
private
def set_post
#post = Post.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def post_params
params.require(:post).permit(:name, :location_id)
end
end
Creating Post with location in Post _form.html.erb
<%= simple_form_for #post do |f| %>
<% if #post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(#post.errors.count, "error") %> prohibited this post from being saved: </h2>
<ul>
<% #post.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<%= f.input :name %>
<%= f.select :location_id, Location.all.at_depth(4) { |l| [ l.name, l.id ] } %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
My question are
First question- f.select :location_id , how display location name, not location id, i am using with simple form
Second question- Post index got error in <%= post.location.name %>
<% #posts.each do |post| %>
<tr>
<td><%= post.name %></td>
<td><%= post.location.name %></td>
<td><%= link_to 'Show', post %></td>
<td><%= link_to 'Edit', edit_post_path(post) %></td>
<td><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %> </td>
</tr>
<% end %>
First question:
Check the simple_form syntax for a dropdown. It is mentioned in the docs and you should be able to get this working by yourself.
Second question:
Does the offending post really have a related location? If it does not have one, it can not display the name of course. To counter these nil errors, use try:
<%= post.location.try(:name) %>
try will call the method name on location only if location is not nil.
For your first question :
Maybe you should read about "options_for_select"
http://guides.rubyonrails.org/form_helpers.html#option-tags-from-a-collection-of-arbitrary-objects
<% cities_array = City.all.map { |city| [city.name, city.id] } %>
<%= options_for_select(cities_array) %>
For your second question:
What is your error ?
Maybe one of your "post.location" is nil.
If so, try:
post.location.name unless post.location.nil?
Hope this can help
I am implementing an application in which i want to change the settings of the application.
While doing so I am getting an error
no routes matches {:action=>"show", :controller=>"settings", format=>"nil"}
while clicking on the open new settings tab.
my index.html is as follows:-
<h1>Listing settings</h1>
<table class="table table-striped table-bordered">
<tr>
<th>ID</th>
<th>Name</th>
<th>Value</th>
<th>Description</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<% #settings.each do |c| %>
<tr>
<td><%= c.id %> </td>
<td><%= c.name %> </td>
<td><%= c.value %> </td>
<td><%= c.description %> </td>
<td><%= link_to 'Edit', {:action => 'edit', :id => c.id} %> </td>
<td><%= link_to 'Delete', {:action => 'delete', :id => c.id},
:data => { :confirm => "Are you sure you want to delete this value?" } %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Setting', {:action => 'new'} %>
My settings controller is as follows:-
class SettingsController < 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 => { :success => true } }
end
end
end
My new.html is as follows:-
<h1>New settings</h1>
<%= form_for #setting do |f| %>
<% if #setting.errors.any? %>
<div id="errorExplanation">
<h2><%= pluralize(#setting.errors.count, "error") %> prohibited this setting from being saved:</h2>
<ul>
<% #setting.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
Id: <%= f.text_field :id %><br>
Name: <%= f.text_field :name %><br>
Values: <%= f.text_field :value %><br>
Description: <%= f.text_field :description %><br>
<% end %>
<%= link_to 'Back', settings_path %>
My routes.rb is as follows:-
Lms::Application.routes.draw do
resources :books do
member do
post 'add'
post 'remove'
end
collection do
get 'add'
get 'list' => "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 => 'books#index'
match ':controller(/:action(/:id))(.:format)'
The strange part is that when i click on new action it is going/redirecting to the show action..I am a bit confused why this is happening..
Can some one help me with this..
To check your routes you can run
rake routes
to inspect if you have the routes defined correctly. Also I would suggest to use
<%= link_to "New Setting", new_setting_pah %>
For your routes definition you are not defining the routes for other methods than add or remove.
I advise you to read this great tutorial on rails routes