I have this very simple controller for managing static pages within my Rails application:
class PagesController < ApplicationController
  def home
  end
  def features
  end
  def pricing
  end
end
How can I get a view template to return its own name, so I can do something like this:
# pricing.html.erb
<h1><%= my_own_name.capitalize %></h1>
# --> "Pricing"
Thanks for any help.
4.3 Routing Parameters
The params hash will always contain the :controller and :action keys, but you should use the methods
controller_nameandaction_nameinstead to access these values.
<h1><%= action_name.capitalize %></h1>
                        So:
  class PagesController < ApplicationController
    def pricing
      @action = params[:action]
    end
  end
  # pricing.html.erb
 <h1><%= @action.capitalize %></h1>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With