app/controllers/users_controller.rb in iqvoc-3.5.7 vs app/controllers/users_controller.rb in iqvoc-4.0.0

- old
+ new

@@ -13,69 +13,48 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. class UsersController < ApplicationController + load_and_authorize_resource - load_and_authorize_resource # cancan magic - def index @users = User.find(:all) - - respond_to do |format| - format.html # index.html.erb - format.xml { render :xml => @users } - end end def new @user = User.new - - respond_to do |format| - format.html # new.html.erb - format.xml { render :xml => @user } - end end def create @user = User.new(params[:user]) - respond_to do |format| - if @user.save - flash[:notice] = I18n.t('txt.controllers.users.successfully_created') - format.html { redirect_to users_path } - else - format.html { render :action => "new" } - end + if @user.save + flash[:success] = I18n.t('txt.controllers.users.successfully_created') + redirect_to users_path + else + render :action => :new end end def edit @user = User.find(params[:id]) end def update @user = User.find(params[:id]) - respond_to do |format| - if @user.update_attributes(params[:user]) - flash[:notice] = I18n.t('txt.controllers.users.successfully_updated') - format.html { redirect_to edit_user_path(:id => @user) } - format.xml { head :ok } - else - format.html { render :action => "edit" } - format.xml { render :xml => @user.errors, :status => :unprocessable_entity } - end + if @user.update_attributes(params[:user]) + flash[:success] = I18n.t('txt.controllers.users.successfully_updated') + redirect_to users_path + else + render :action => :edit end end def destroy @user = User.find(params[:id]) @user.destroy - respond_to do |format| - format.html { redirect_to users_path } - format.xml { head :ok } - end + redirect_to users_path end - end