Search code examples
ruby-on-railsrubyactivescaffold

Rails ActiveScaffold creating link for column


I am using ActiveScaffold gem for my Rails 4 application. I would like to add link to one of column(full_name) for User model. So once I click the user full name it will do some action. I know how to add custom action_links like show, edit, destroy or add other custom action_links next to them.

But I would just like to make one of my column as link rather than adding addition button on the page. I looked at the documentation and found something like this:

Inside `users_controller.rb`

config.columns[:full_name].link

But it's not doing anything. Please guide me how to add link to one of columns in the row and how to define method to perform some action once link has been clicked.


Solution

  • You can override a column's behavior by defining a method like this in the UsersHelper module:

    def user_full_name_column(record, column)
      link_to h(record.full_name), "url_value_here"
    end
    

    See: Column Overrides (List)