ruby - Create Simple Rails Filter for a Table -


newest version of rails.

i have table positions contains several columns, 1 in question 'status'. string based column holds values 'add' 'error' 'drop'. have table rendering in view , wish create links filter data returned in table, limited status.

 add | error  id | name | status 1    bob    add 2    jim    error 

if clicked add link above table in view change data in table show bob, since has status of add. if clicked error link display jim.

i can limit view data @positions = position.where(:status => "add") want invoke limit upon link click.

thanks , if need define further please let me know.

add link_to links pass respective status params, adjust controller action , return @positions based on params[:status] if present.

link

link_to "error", positions_path(:status => "error") 

controller

if params[:status].present?    @positions = position.where(status: params[:status]) else   @positions = position.all end 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -