Created
November 18, 2015 10:24
-
-
Save ekumachidi/af5949fae670e7745503 to your computer and use it in GitHub Desktop.
This file contains 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 new | |
@user = User.new | |
@package = Package.all | |
end | |
def create | |
@user = user.new(user_params) | |
if @user.save | |
redirect_to :action => ‘list’ | |
else | |
@packages = Packages.all | |
render :new | |
end | |
end | |
def user_params | |
params.require(:user).permit(:name, :phone, :package_id) | |
end | |
def list | |
@user = user.all | |
end | |
def show | |
@user = user.find(params[:id]) | |
end | |
def update | |
@user = user.find(params[:id]) | |
if @user.update_attributes(user_param) | |
redirect_to :action => ‘show’, :id => @user | |
else | |
render :edit #that is if u have an edit action/view | |
end | |
end | |
def edit | |
@user = user.find(params[:id]) | |
end | |
def delete | |
user.find(params[:id]).destroy | |
redirect_to :action => ‘list’ | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment