The Artima Developer Community
Sponsored Link

Java Buzz Forum
Re: Rails for Struts-ters

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Brian McCallister

Posts: 1282
Nickname: frums
Registered: Sep, 2003

Brian McCallister is JustaProgrammer who thinks too much.
Re: Rails for Struts-ters Posted: Feb 15, 2005 5:44 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Brian McCallister.
Original Post: Re: Rails for Struts-ters
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
Latest Java Buzz Posts
Latest Java Buzz Posts by Brian McCallister
Latest Posts From Waste of Time

Advertisement

Got some feedback on my previous post which is probably best reprinted (now that I've gotten permission) verbatim:

Great article on the comparison of Struts and Rails. 
I have a few pointers on how you can make it even better.

1. Rename app/views/layout/scaffold.rb to app/views/layout/application.rb -- 
then its automatically picked up by all controllers.

2. Using model :user is not necessary unless you don't follow the 
User => user.rb model. When you do (and the generators ensure that you do 
pretty much all the time), the User model is automatically included when the 
class is referenced.

3. These are not necessary: helper_attr :return_to, :user_login. All instance 
variables assigned in a controller action is automatically made available to the view.

I'm not sure what the pass_thru is about, but in any case, here's a more idiomatic 
Rails controller for your example:

class LoginController < ApplicationController
  def index
    if @session['user'] = User.authenticate(@params['user_login'])
      logger.info "User logged in: #{@session['user']}"
      redirect_to_path(@params['return_to'])
    else
      @session['return_to'] = @params['return_to']
      redirect_to :controller => 'rsvp',
                  :action => 'select_invitation',
                  :params => { 'name' => @params['user_login'] }
    end
  end

  def pass_thru
    @return_to = @params['return_to']
    render_action 'login'
  end

  def logout
    reset_session
    redirect_to :controller => 'information', :action => 'index'
  end
end
--
David Heinemeier Hansson

Nice when the guy who wwrote the framework is poking at your code ;-)

Read: Re: Rails for Struts-ters

Topic: PgsLookAndFeel 0.2 Released Previous Topic   Next Topic Topic: Text Internationalization in Orca TDD Build Framework

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use