Class: NyrosForm2::UsersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- NyrosForm2::UsersController
- Defined in:
- app/controllers/nyros_form2/users_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/nyros_form2/users_controller.rb', line 17 def create @user = User.new(user_params) respond_to do |format| if @user.save format.html { redirect_to users_path, notice: 'Contact was successfully created.' } format.json { render json: @user, status: :created, location: @user } else format.html { render action: "new" } format.json { render json: @user.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/nyros_form2/users_controller.rb', line 47 def destroy @user = User.find(params[:id]) @user.destroy respond_to do |format| format.html { redirect_to users_url, notice: 'user succesfully deleted' } format.json { head :no_content} format.js { render :layout => false } end end |
#edit ⇒ Object
34 35 36 |
# File 'app/controllers/nyros_form2/users_controller.rb', line 34 def edit @user = User.find(params[:id]) end |
#index ⇒ Object
5 6 7 8 9 10 11 |
# File 'app/controllers/nyros_form2/users_controller.rb', line 5 def index @users = User.all.order('created_at DESC') respond_to do |format| format.html format.json { render json: @users } end end |
#new ⇒ Object
13 14 15 |
# File 'app/controllers/nyros_form2/users_controller.rb', line 13 def new @user = User.new end |
#show ⇒ Object
30 31 32 |
# File 'app/controllers/nyros_form2/users_controller.rb', line 30 def show @user = User.find(params[:id]) end |
#update ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'app/controllers/nyros_form2/users_controller.rb', line 38 def update @user = User.find(params[:id]) if @user.update_attributes(user_params) redirect_to users_path else render :edit end end |