class ChannelsController < ApplicationController
def index
@channels = current_user.channels
respond_with(@channels)
end
def new
@channel = current_user.channels.build
respond_with(@channel)
end
def create
@channel = current_user.channels.build(params[:channel])
@channel.save
respond_with(@channel)
end
def show
@channel = current_user.channels.find(params[:id])
respond_with(@channel)
end
def edit
@channel = current_user.channels.find(params[:id])
respond_with(@channel)
end
def update
@channel = current_user.channels.find(params[:id])
@channel.update_attributes(params[:channel])
respond_with(@channel)
end
private
def current_user
@current_user ||= User.find(params[:user_id])
end
end
问问题
59 次