summaryrefslogtreecommitdiff
path: root/app/controllers/tutorials_controller.rb
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2013-07-26 19:13:40 -0600
committermo khan <mo@mokhan.ca>2013-07-26 19:15:04 -0600
commit12832c1fb4ed327abdbd62e5b882f93fd426c85f (patch)
treedb097e16a36776890010437d003cd751b7953d71 /app/controllers/tutorials_controller.rb
parent04e227b70876e91087710256e3908da148c9a896 (diff)
fix tutorials controller specs to be rails 4 compatible
Diffstat (limited to 'app/controllers/tutorials_controller.rb')
-rw-r--r--app/controllers/tutorials_controller.rb29
1 files changed, 14 insertions, 15 deletions
diff --git a/app/controllers/tutorials_controller.rb b/app/controllers/tutorials_controller.rb
index b9e74dd1..6080f275 100644
--- a/app/controllers/tutorials_controller.rb
+++ b/app/controllers/tutorials_controller.rb
@@ -19,28 +19,23 @@ class TutorialsController < ApplicationController
end
def create
- @tutorial = current_user.tutorials.create(params[:tutorial])
+ @tutorial = current_user.tutorials.create(tutorial_params)
current_user.tag(@tutorial, :with => params[:tutorial_tags], :on => :tags)
- respond_to do |format|
- if @tutorial.save
- format.html { redirect_to( '/tutorials', :notice => 'the tutorial was successfully added.' ) }
- else
- @user = current_user
- flash[:error] = @tutorial.errors.full_messages
- format.html { render :action => "new" }
- end
+ if @tutorial.save
+ redirect_to tutorials_path, :notice => t(:tutorial_saved)
+ else
+ flash[:error] = @tutorial.errors.full_messages
+ render :new
end
end
def update
@tutorial = current_user.tutorials.find(params[:id])
current_user.tag(@tutorial, :with => params[:tutorial_tags], :on => :tags)
- respond_to do |format|
- if @tutorial.update_attributes(params[:tutorial])
- format.html { redirect_to(@tutorial, :notice => 'the tutorial was successfully updated.') }
- else
- format.html { render :action => "edit" }
- end
+ if @tutorial.update_attributes(tutorial_params)
+ redirect_to @tutorial
+ else
+ render :edit
end
end
@@ -52,4 +47,8 @@ class TutorialsController < ApplicationController
format.html { redirect_to(tutorials_url) }
end
end
+
+ def tutorial_params
+ params.require(:tutorial).permit(:url, :heading)
+ end
end