Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def create1
- # is this unsecure? should we grab user_id from the session
- params[:venue]['user_id'] = params[:user_id]
- begin
- venue = Venue.create(params[:venue])
- @user_venues = @user.venues
- render :partial => 'venue_select_box', :success => true, :status => :ok
- rescue ActiveRecord::RecordInvalid
- render :text => 'Put errors in here', :success => false, :status => :unprocessable_entity
- end
- end
- def create2
- # is this unsecure? should we grab user_id from the session
- params[:venue]['user_id'] = params[:user_id]
- venue = Venue.new(params[:venue])
- if venue.save
- @user_venues = @user.venues
- render :partial => 'venue_select_box', :success => true, :status => :ok
- else
- render :text => 'Put errors in here', :success => false, :status => :unprocessable_entity
- end
- end
- class VenuesController < ApplicationController
- def create
- @venue = @user.venues.create!(params[:venue])
- render :partial => 'venue_select_box', :success => true, :status => :ok
- end
- rescue_from ActiveRecord::RecordInvalid do
- render :text => 'Put errors in here', :success => false, :status => :unprocessable_entity
- end
- end
Add Comment
Please, Sign In to add comment