class ApplicationController < ActionController::Base
before_filter :authenticate
def authenticate
# How do we know which controller and action was targetted?
params[:controller]
params[:action]
# OR
controller.controller_name
controller.action_name
end
end
Related Contents:
- How to remove a key from Hash and get the remaining hash in Ruby/Rails?
- How can I specify a local gem in my Gemfile?
- Equivalent of .try() for a hash to avoid “undefined method” errors on nil? [duplicate]
- do..end vs curly braces for blocks in Ruby
- Rails hidden field undefined method ‘merge’ error
- Is the server running on host “localhost” (::1) and accepting TCP/IP connections on port 5432?
- What is the difference between `after_create` and `after_save` and when to use which?
- Convert duration to hours:minutes:seconds (or similar) in Rails 3 or Ruby
- Devise password reset from Rails console
- Convert UTC to local time in Rails 3
- validation custom message for rails 3
- Hash remove all except specific keys
- How to check if a number is included in a range (in one statement)?
- Should I specify exact versions in my Gemfile?
- Rails Admin vs. ActiveAdmin [closed]
- Cannot execute “rails console” due to an error with readline
- before_filter with parameters
- How to get a single column’s values into an array
- how to safely replace all whitespaces with underscores with ruby?
- In Ruby on Rails, to extend the String class, where should the code be put in?
- In Rails, what’s the difference between find_each and where?
- PG::Error: SELECT DISTINCT, ORDER BY expressions must appear in select list
- Where to put Ruby helper methods for Rails controllers?
- Parsing string to add to URL-encoded URL
- incompatible character encodings: ASCII-8BIT and UTF-8
- Can we call a Controller’s method from a view (as we call from helper ideally)?
- How to get a query string from a URL in Rails
- Rails 3. How to display two decimal places in edit form?
- Rails how to delete a file without failing on error
- Ruby on Rails 3 : “superclass mismatch for class …”
- Is there a Rails Console command (Rails 3+) to reload changed code?
- Ruby syntax: break out from ‘each.. do..’ block
- Find the newest record in Rails 3
- Role does not exist and unable to create database when using PostgreSQL
- Why is it best to store a telephone number as a string vs. integer?
- Upgrading from Rails 3 to Rails 3.1 [closed]
- How to count lines of code?
- How can I reload the current page in Ruby on Rails?
- Rails 3 – no such file to load — openssl
- Difference between resource and resources in rails routing?
- Possible to alias a belongs_to association in Rails?
- What is the best/easy way to validate an email address in Ruby?
- Ruby on Rails “invalid byte sequence in UTF-8” due to bot
- ruby on rails how to deal with NaN
- How to test rendering a partial with RSpec
- Ruby on Rails 3 howto make ‘OR’ condition
- Could not find rails (>= 0) amongst [] (Gem::LoadError)
- Adding foreign key to a rails model
- How to call ApplicationController methods from ApplicationHelper
- How can I group this array of hashes?