Here's the problem:
I have a Controller (say ExampleController) which has a method "sort_column" and it has the following code :
Example.column_names.include?(params[:sort]) ? params[:sort] : 'title'
which says that, In the "Example" model, if you find any column names that include the params[sort], whitelist them.
I have declared this method "sort_column" as a helper method in my controller by declaring
Now, my question is that, upon render of index page, i sorted the table by default to have asc order. If i try to test the index.html.erb, which renders by having the sort_column as 'title', i am blocked with an error saying this
Failure/Error: direction = (column == sort_column) && (sort_direction == 'asc' ? 'desc' : 'asc')
ActionView::Template::Error: undefined local variable or method `sort_column' for #<#<Class:0x00007fd4f085c380>:0x00007fd4eb195c90>
Hitting my head from a couple of days with this error !
Controller methods are not available in the view unless you expose them with
Join 30,242+ developers who get early access to new screencasts, articles, guides, updates, and more.