jeudi 27 juillet 2017

how to create new action for listing all data while i am already used show controller

This is my jobs controller

def index
  @job = Job.new
end
def create
  @job = Job.new(job_params)
 if @job.save
  flash[:notice] = "resume is uploaded"
  redirect_to @job
 else
  flash[:notice] = "resume is not uploaded"
  redirect_to blogs_path
 end
end

def list
  @jobs = Job.all
end
def messages
 @pages = Page.all
end
def show
 @job = Job.find(params[:id]) 
end
def new
 @post = Post.new
end    

My error is if i will search jobs/list,it will take list is a id.that means id='list'.why it does not take the list is action.

my confif/routes.rb resources :jobs do collection do get ':list' :as => 'list' end end

This also i added but is not working

get 'jobs/list'

Aucun commentaire:

Enregistrer un commentaire