--- !ruby/object:RI::ClassDescription 
attributes: 
- !ruby/object:RI::Attribute 
  comment: 
  - !ruby/struct:SM::Flow::P 
    body: Returns the name of the action this controller is processing.
  name: action_name
  rw: RW
- !ruby/object:RI::Attribute 
  comment: 
  - !ruby/struct:SM::Flow::P 
    body: Holds the hash of variables that are passed on to the template class to be made available to the view. This hash is generated by taking a snapshot of all the instance variables in the current scope just before a template is rendered.
  name: assigns
  rw: RW
class_methods: 
- !ruby/object:RI::MethodSummary 
  name: append_view_path
- !ruby/object:RI::MethodSummary 
  name: controller_class_name
- !ruby/object:RI::MethodSummary 
  name: controller_name
- !ruby/object:RI::MethodSummary 
  name: controller_path
- !ruby/object:RI::MethodSummary 
  name: exempt_from_layout
- !ruby/object:RI::MethodSummary 
  name: filter_parameter_logging
- !ruby/object:RI::MethodSummary 
  name: hidden_actions
- !ruby/object:RI::MethodSummary 
  name: hide_action
- !ruby/object:RI::MethodSummary 
  name: prepend_view_path
- !ruby/object:RI::MethodSummary 
  name: process_cgi
- !ruby/object:RI::MethodSummary 
  name: process_test
- !ruby/object:RI::MethodSummary 
  name: view_paths
- !ruby/object:RI::MethodSummary 
  name: view_paths=
comment: 
- !ruby/struct:SM::Flow::P 
  body: Action Controllers are the core of a web request in Rails. They are made up of one or more actions that are executed on request and then either render a template or redirect to another action. An action is defined as a public method on the controller, which will automatically be made accessible to the web-server through Rails Routes.
- !ruby/struct:SM::Flow::P 
  body: "A sample controller could look like this:"
- !ruby/struct:SM::Flow::VERB 
  body: "  class GuestBookController &lt; ActionController::Base\n    def index\n      @entries = Entry.find(:all)\n    end\n\n    def sign\n      Entry.create(params[:entry])\n      redirect_to :action =&gt; &quot;index&quot;\n    end\n  end\n"
- !ruby/struct:SM::Flow::P 
  body: Actions, by default, render a template in the <tt>app/views</tt> directory corresponding to the name of the controller and action after executing code in the action. For example, the <tt>index</tt> action of the GuestBookController would render the template <tt>app/views/guestbook/index.erb</tt> by default after populating the <tt>@entries</tt> instance variable.
- !ruby/struct:SM::Flow::P 
  body: Unlike index, the sign action will not render a template. After performing its main purpose (creating a new entry in the guest book), it initiates a redirect instead. This redirect works by returning an external &quot;302 Moved&quot; HTTP response that takes the user to the index action.
- !ruby/struct:SM::Flow::P 
  body: The index and sign represent the two basic action archetypes used in Action Controllers. Get-and-show and do-and-redirect. Most actions are variations of these themes.
- !ruby/struct:SM::Flow::H 
  level: 2
  text: Requests
- !ruby/struct:SM::Flow::P 
  body: Requests are processed by the Action Controller framework by extracting the value of the &quot;action&quot; key in the request parameters. This value should hold the name of the action to be performed. Once the action has been identified, the remaining request parameters, the session (if one is available), and the full request with all the HTTP headers are made available to the action through instance variables. Then the action is performed.
- !ruby/struct:SM::Flow::P 
  body: "The full request object is available with the request accessor and is primarily used to query for HTTP headers. These queries are made by accessing the environment hash, like this:"
- !ruby/struct:SM::Flow::VERB 
  body: "  def server_ip\n    location = request.env[&quot;SERVER_ADDR&quot;]\n    render :text =&gt; &quot;This server hosted at #{location}&quot;\n  end\n"
- !ruby/struct:SM::Flow::H 
  level: 2
  text: Parameters
- !ruby/struct:SM::Flow::P 
  body: All request parameters, whether they come from a GET or POST request, or from the URL, are available through the params method which returns a hash. For example, an action that was performed through <tt>/weblog/list?category=All&amp;limit=5</tt> will include <tt>{ &quot;category&quot; =&gt; &quot;All&quot;, &quot;limit&quot; =&gt; 5 }</tt> in params.
- !ruby/struct:SM::Flow::P 
  body: "It's also possible to construct multi-dimensional parameter hashes by specifying keys using brackets, such as:"
- !ruby/struct:SM::Flow::VERB 
  body: "  &lt;input type=&quot;text&quot; name=&quot;post[name]&quot; value=&quot;david&quot;&gt;\n  &lt;input type=&quot;text&quot; name=&quot;post[address]&quot; value=&quot;hyacintvej&quot;&gt;\n"
- !ruby/struct:SM::Flow::P 
  body: A request stemming from a form holding these inputs will include <tt>{ &quot;post&quot; =&gt; { &quot;name&quot; =&gt; &quot;david&quot;, &quot;address&quot; =&gt; &quot;hyacintvej&quot; } }</tt>. If the address input had been named &quot;post[address][street]&quot;, the params would have included <tt>{ &quot;post&quot; =&gt; { &quot;address&quot; =&gt; { &quot;street&quot; =&gt; &quot;hyacintvej&quot; } } }</tt>. There's no limit to the depth of the nesting.
- !ruby/struct:SM::Flow::H 
  level: 2
  text: Sessions
- !ruby/struct:SM::Flow::P 
  body: Sessions allows you to store objects in between requests. This is useful for objects that are not yet ready to be persisted, such as a Signup object constructed in a multi-paged process, or objects that don't change much and are needed all the time, such as a User object for a system that requires login. The session should not be used, however, as a cache for objects where it's likely they could be changed unknowingly. It's usually too much work to keep it all synchronized -- something databases already excel at.
- !ruby/struct:SM::Flow::P 
  body: "You can place objects in the session by using the <tt>session</tt> method, which accesses a hash:"
- !ruby/struct:SM::Flow::VERB 
  body: "  session[:person] = Person.authenticate(user_name, password)\n"
- !ruby/struct:SM::Flow::P 
  body: "And retrieved again through the same hash:"
- !ruby/struct:SM::Flow::VERB 
  body: "  Hello #{session[:person]}\n"
- !ruby/struct:SM::Flow::P 
  body: "For removing objects from the session, you can either assign a single key to <tt>nil</tt>:"
- !ruby/struct:SM::Flow::VERB 
  body: "  # removes :person from session\n  session[:person] = nil\n"
- !ruby/struct:SM::Flow::P 
  body: or you can remove the entire session with <tt>reset_session</tt>.
- !ruby/struct:SM::Flow::P 
  body: Sessions are stored by default in a browser cookie that's cryptographically signed, but unencrypted. This prevents the user from tampering with the session but also allows him to see its contents.
- !ruby/struct:SM::Flow::P 
  body: Do not put secret information in cookie-based sessions!
- !ruby/struct:SM::Flow::P 
  body: "Other options for session storage are:"
- !ruby/object:SM::Flow::LIST 
  contents: 
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: ActiveRecordStore - Sessions are stored in your database, which works better than PStore with multiple app servers and, unlike CookieStore, hides your session contents from the user. To use ActiveRecordStore, set
  - !ruby/struct:SM::Flow::VERB 
    body: "  config.action_controller.session_store = :active_record_store\n"
  - !ruby/struct:SM::Flow::P 
    body: in your <tt>config/environment.rb</tt> and run <tt>rake db:sessions:create</tt>.
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: "MemCacheStore - Sessions are stored as entries in your memcached cache. Set the session store type in <tt>config/environment.rb</tt>:"
  - !ruby/struct:SM::Flow::VERB 
    body: "  config.action_controller.session_store = :mem_cache_store\n"
  - !ruby/struct:SM::Flow::P 
    body: This assumes that memcached has been installed and configured properly. See the MemCacheStore docs for more information.
  type: :BULLET
- !ruby/struct:SM::Flow::H 
  level: 2
  text: Responses
- !ruby/struct:SM::Flow::P 
  body: Each action results in a response, which holds the headers and document to be sent to the user's browser. The actual response object is generated automatically through the use of renders and redirects and requires no user intervention.
- !ruby/struct:SM::Flow::H 
  level: 2
  text: Renders
- !ruby/struct:SM::Flow::P 
  body: "Action Controller sends content to the user by using one of five rendering methods. The most versatile and common is the rendering of a template. Included in the Action Pack is the Action View, which enables rendering of ERb templates. It's automatically configured. The controller passes objects to the view by assigning instance variables:"
- !ruby/struct:SM::Flow::VERB 
  body: "  def show\n    @post = Post.find(params[:id])\n  end\n"
- !ruby/struct:SM::Flow::P 
  body: "Which are then automatically available to the view:"
- !ruby/struct:SM::Flow::VERB 
  body: "  Title: &lt;%= @post.title %&gt;\n"
- !ruby/struct:SM::Flow::P 
  body: "You don't have to rely on the automated rendering. Especially actions that could result in the rendering of different templates will use the manual rendering methods:"
- !ruby/struct:SM::Flow::VERB 
  body: "  def search\n    @results = Search.find(params[:query])\n    case @results\n      when 0 then render :action =&gt; &quot;no_results&quot;\n      when 1 then render :action =&gt; &quot;show&quot;\n      when 2..10 then render :action =&gt; &quot;show_many&quot;\n    end\n  end\n"
- !ruby/struct:SM::Flow::P 
  body: Read more about writing ERb and Builder templates in link:classes/ActionView/Base.html.
- !ruby/struct:SM::Flow::H 
  level: 2
  text: Redirects
- !ruby/struct:SM::Flow::P 
  body: "Redirects are used to move from one action to another. For example, after a <tt>create</tt> action, which stores a blog entry to a database, we might like to show the user the new entry. Because we're following good DRY principles (Don't Repeat Yourself), we're going to reuse (and redirect to) a <tt>show</tt> action that we'll assume has already been created. The code might look like this:"
- !ruby/struct:SM::Flow::VERB 
  body: "  def create\n    @entry = Entry.new(params[:entry])\n    if @entry.save\n      # The entry was saved correctly, redirect to show\n      redirect_to :action =&gt; 'show', :id =&gt; @entry.id\n    else\n      # things didn't go so well, do something else\n    end\n  end\n"
- !ruby/struct:SM::Flow::P 
  body: In this case, after saving our new entry to the database, the user is redirected to the <tt>show</tt> method which is then executed.
- !ruby/struct:SM::Flow::H 
  level: 2
  text: Calling multiple redirects or renders
- !ruby/struct:SM::Flow::P 
  body: "An action may contain only a single render or a single redirect. Attempting to try to do either again will result in a DoubleRenderError:"
- !ruby/struct:SM::Flow::VERB 
  body: "  def do_something\n    redirect_to :action =&gt; &quot;elsewhere&quot;\n    render :action =&gt; &quot;overthere&quot; # raises DoubleRenderError\n  end\n"
- !ruby/struct:SM::Flow::P 
  body: If you need to redirect on the condition of something, then be sure to add &quot;and return&quot; to halt execution.
- !ruby/struct:SM::Flow::VERB 
  body: "  def do_something\n    redirect_to(:action =&gt; &quot;elsewhere&quot;) and return if monkeys.nil?\n    render :action =&gt; &quot;overthere&quot; # won't be called unless monkeys is nil\n  end\n"
constants: 
- !ruby/object:RI::Constant 
  comment: 
  name: DEFAULT_RENDER_STATUS_CODE
  value: "\"200 OK\""
full_name: ActionController::Base
includes: 
- !ruby/object:RI::IncludedModule 
  name: StatusCodes
instance_methods: 
- !ruby/object:RI::MethodSummary 
  name: append_view_path
- !ruby/object:RI::MethodSummary 
  name: controller_class_name
- !ruby/object:RI::MethodSummary 
  name: controller_name
- !ruby/object:RI::MethodSummary 
  name: controller_path
- !ruby/object:RI::MethodSummary 
  name: default_url_options
- !ruby/object:RI::MethodSummary 
  name: expires_in
- !ruby/object:RI::MethodSummary 
  name: expires_now
- !ruby/object:RI::MethodSummary 
  name: head
- !ruby/object:RI::MethodSummary 
  name: prepend_view_path
- !ruby/object:RI::MethodSummary 
  name: process_with_test
- !ruby/object:RI::MethodSummary 
  name: redirect_to
- !ruby/object:RI::MethodSummary 
  name: render
- !ruby/object:RI::MethodSummary 
  name: render_to_string
- !ruby/object:RI::MethodSummary 
  name: reset_session
- !ruby/object:RI::MethodSummary 
  name: session_enabled?
- !ruby/object:RI::MethodSummary 
  name: url_for
- !ruby/object:RI::MethodSummary 
  name: view_paths
- !ruby/object:RI::MethodSummary 
  name: view_paths=
name: Base
superclass: Object
