Class: MerbWords::Passwords
- Inherits:
-
Application
- Object
- Merb::Controller
- Application
- MerbWords::Passwords
- Defined in:
- app/controllers/passwords.rb
Instance Method Summary collapse
- #create ⇒ Object
- #create_post ⇒ Object
- #delete ⇒ Object
- #delete_delete ⇒ Object
- #exit ⇒ Object
- #read ⇒ Object
- #read_post ⇒ Object
- #update ⇒ Object
- #update_post ⇒ Object
Instance Method Details
#create ⇒ Object
12 13 14 |
# File 'app/controllers/passwords.rb', line 12 def create display(@password = Password.new, :layout => false) end |
#create_post ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/passwords.rb', line 16 def create_post password = Password.new(params[:password]) if password.save session[:mui_password_id] = password.id session[:mui_message] = url(:merb_ui_message, :title => 'Password created', :tone => 'positive') mui_window_redirect else session[:mui_message] = url(:merb_ui_message, :title => 'Unable to create password', :body => mui_list(password.errors), :tone => 'negative') session[:mui_window] = slice_url(:password_create) mui_window_redirect end end |
#delete ⇒ Object
64 65 66 |
# File 'app/controllers/passwords.rb', line 64 def delete render :layout => false end |
#delete_delete ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/controllers/passwords.rb', line 68 def delete_delete password = Password.get!(session[:mui_password_id]) if password.destroy session.delete(:mui_password_id) session[:mui_message] = url(:merb_ui_message, :title => 'Password deleted', :tone => 'positive') mui_window_redirect else session[:mui_message] = url(:merb_ui_message, :title => 'Unable to delete password', :body => mui_list(password.errors), :tone => 'negative') session[:mui_window] = slice_url(:password_delete) mui_window_redirect end end |
#exit ⇒ Object
6 7 8 9 10 |
# File 'app/controllers/passwords.rb', line 6 def exit session.delete(:mui_password_id) session[:mui_message] = url(:merb_ui_message, :title => 'Exited', :tone => 'positive') mui_window_redirect end |
#read ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/controllers/passwords.rb', line 29 def read if Password.first display(@password = Password.new, :layout => false) else redirect slice_url(:password_create) end end |
#read_post ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/passwords.rb', line 37 def read_post encrypted = encrypt(params[:password]) if password_match = Password.first(:encrypted => encrypted) session[:mui_password_id] = password_match.id session[:mui_message] = url(:merb_ui_message, :title => 'Password correct', :tone => 'positive') else session[:mui_message] = url(:merb_ui_message, :title => 'Password incorrect', :tone => 'negative') session[:mui_window] = slice_url(:password_read) end mui_window_redirect end |
#update ⇒ Object
49 50 51 |
# File 'app/controllers/passwords.rb', line 49 def update display(@password = Password.new, :layout => false) end |
#update_post ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/passwords.rb', line 53 def update_post password = Password.get!(session[:mui_password_id]) if password.update_attributes(params[:password]) session[:mui_message] = url(:merb_ui_message, :title => 'Password updated', :tone => 'positive') else session[:mui_message] = url(:merb_ui_message, :title => 'Unable to update password', :body => mui_list(password.errors), :tone => 'negative') session[:mui_window] = slice_url(:password_update) end mui_window_redirect end |