This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| response.should redirect_to named_route_path(resource.id, :param => "true") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Rack::Utils.parse_query(URI.parse(response.redirect_url).query)["param"].should == "1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CGI.parse(URI.parse(response.redirect_url).query) if URI.parse(response.redirect_url).query.present? | |
| => {"x"=>["1"], "y"=>["2"]} | |
| Rack::Utils.parse_query(URI.parse(response.redirect_url).query | |
| => {"x"=>"1", "y"=>"2"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| URI.parse(response.redirect_url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scope :path1, :as => 'path1' do | |
| constraints(SubdomainConstraints) do | |
| resources :my_resource | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace :path1 do | |
| resources :my_resource | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def require_email | |
| errors.add(:email, "Email is required") unless email.present? | |
| if email.present? | |
| errors.add(:email, "Email is already taken") if email_in_use?(email) | |
| end | |
| errors.empty? | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def register_user | |
| password = User.send(:generate_token, 'encrypted_password').slice(0, 6) | |
| user = User.create!(:name => name, :email => email, :age => age, | |
| :password => password, :password_confirmation => password) | |
| Notifications.signup(user, password).deliver | |
| self.user = user | |
| self.save! | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def update | |
| @registration = Registration.find(params[:id]) | |
| redirect_to users_path(@registration.user_id) and return if @registration.state == 'complete' | |
| if @registration.update_attributes(params[:registration]) | |
| if @registration.next! | |
| if @registration.state == 'complete' | |
| #can only reach this block on first completion -- or next will have failed | |
| sign_in(:user, @registration.user) | |
| redirect_to user_show_path and return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| state_machine do | |
| state :email, :exit => lambda {|reg| reg.errors.clear } | |
| state :age, :exit => lambda {|reg| reg.errors.clear } | |
| state :complete, :enter => :register_user | |
| event :next do | |
| transitions :from => :email, :to => :age, :guard => :guard_to_age | |
| transitions :from => :age, :to => :complete, :guard => :guard_to_complete | |
| # do not allow complete => complete | |
| end |