Skip to content

Commit 3019dd2

Browse files
committed
Merge pull request #68 from sergii/cleanup_actions
Clean up actions
2 parents 5f81fb8 + aa2ffdd commit 3019dd2

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

app/controllers/activities_controller.rb

+4-5
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ def index
3434
def create
3535
@activity = Channel.find(params[:channel_id]).activities.build(params[:activity])
3636
@activity.user_id = current_user.id if @activity.action == "message"
37-
if @activity.save
38-
respond_to do |format|
37+
38+
respond_to do |format|
39+
if @activity.save
3940
format.json { render :json => @activity, :status => :created }
40-
end
41-
else
42-
respond_to do |format|
41+
else
4342
format.json { render :json => @activity.errors, :status => :unprocessable_entity }
4443
end
4544
end

app/controllers/channels_controller.rb

+6-10
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ def index
2626

2727
def create
2828
@channel = Channel.new(params[:channel])
29-
if @channel.save
30-
respond_to do |format|
29+
respond_to do |format|
30+
if @channel.save
3131
format.json { render :json => @channel, :status => :created }
32-
end
33-
else
34-
respond_to do |format|
32+
else
3533
format.json { render :json => @channel.errors, :status => :unprocessable_entity }
3634
end
3735
end
@@ -46,12 +44,10 @@ def show
4644

4745
def update
4846
@channel = Channel.find(params[:id])
49-
if @channel.update_attributes(params[:channel])
50-
respond_to do |format|
47+
respond_to do |format|
48+
if @channel.update_attributes(params[:channel])
5149
format.json { render :json => @channel, :status => :ok }
52-
end
53-
else
54-
respond_to do |format|
50+
else
5551
format.json { render :json => @channel.errors, :status => :unprocessable_entity }
5652
end
5753
end

0 commit comments

Comments
 (0)