I have two models as follows:
module FullcalendarEngine
class Event < ActiveRecord::Base
belongs_to :profile, polymorphic: :true
accepts_nested_attributes_for :profile
end
end
class UserProfile < ActiveRecord::Base
has_many :fullcalendar_engine_events, as: :profile, class_name: 'FullcalendarEngine::Event'
end
I can save this relation through the console:
l = UserProfile.first
e = l.fullcalendar_engine_events.build
e.save!
However, when I try it through a form submission, I get the following error:
NameError - uninitialized constant FullcalendarEngine::Event::Profile:
activerecord (4.1.5) lib/active_record/inheritance.rb:133:in `compute_type'
activerecord (4.1.5) lib/active_record/reflection.rb:221:in `klass'
activerecord (4.1.5) lib/active_record/nested_attributes.rb:545:in `raise_nested_attributes_record_not_found!'
activerecord (4.1.5) lib/active_record/nested_attributes.rb:387:in `assign_nested_attributes_for_one_to_one_association'
activerecord (4.1.5) lib/active_record/nested_attributes.rb:343:in `profile_attributes='
activerecord (4.1.5) lib/active_record/attribute_assignment.rb:45:in `public_send'
activerecord (4.1.5) lib/active_record/attribute_assignment.rb:45:in `_assign_attribute'
activerecord (4.1.5) lib/active_record/attribute_assignment.rb:56:in `block in assign_nested_parameter_attributes'
activerecord (4.1.5) lib/active_record/attribute_assignment.rb:56:in `each'
activerecord (4.1.5) lib/active_record/attribute_assignment.rb:56:in `assign_nested_parameter_attributes'
activerecord (4.1.5) lib/active_record/attribute_assignment.rb:36:in `assign_attributes'
activerecord (4.1.5) lib/active_record/core.rb:455:in `init_attributes'
activerecord (4.1.5) lib/active_record/core.rb:198:in `initialize'
activerecord (4.1.5) lib/active_record/inheritance.rb:30:in `new'
activerecord (4.1.5) lib/active_record/inheritance.rb:30:in `new'
This is the controller and form:
#profile = Profile.find(params[:profile])
#event = #profile.fullcalendar_engine_events.build
<%= form_for #event %>
<%= f.fields_for :profile, #profile do |builder| %>
<%= builder.hidden_field :id %>
<% end %>
<% end %>
What's submitted to server (I use ... to remove unncessary stuff):
Parameters: { ... "event"=>{ ... , "profile_attributes"=>{"id"=>"2"}}}
I've used polymorphic relations in the past with fields_for. So I am not sure what's going on here.
At the FullcalendarEngine::Event class, your belongs_to should be declared like this:
belongs_to :profile, polymorphic: :true, class_name: "::Profile"
The '::' forces the const lookup to happen from the root of the namespaces instead of inside the current namespace.
Related
I am currently trying to implement activity_notification gem. The issue I am having, is the gem is searching for the user_id, but I have implemented friendly_id and the gem is unable to find the user. The parameters show {"target_type"=>"users", "devise_type"=>"users", "user_id"=>"dannytom222"} and then the gem fails with Couldn't find User. I'm using the predefined controller for the gem, and cannot locate the method that is throwing this error.
In my stack trace, it shows
def find_by!(*args) # :nodoc:
find_by(*args) || raise(RecordNotFound.new("Couldn't find #{name}", name))
end
Full trace
activerecord (5.1.5) lib/active_record/core.rb:228:in `find_by!'
activity_notification (1.4.4) lib/activity_notification/controllers/common_controller.rb:28:in `set_target'
activesupport (5.1.5) lib/active_support/callbacks.rb:413:in `block in make_lambda'
activesupport (5.1.5) lib/active_support/callbacks.rb:197:in `block (2 levels) in halting'
actionpack (5.1.5) lib/abstract_controller/callbacks.rb:12:in `block (2 levels) in <module:Callbacks>'
activesupport (5.1.5) lib/active_support/callbacks.rb:198:in `block in halting'
friendly_id for user.rb
extend FriendlyId
friendly_id :username, use: :slugged
migration file for friendly_id slug
class AddSlugToUsers < ActiveRecord::Migration[5.1]
def change
add_column :users, :slug, :string
add_index :users, :slug, unique: true
end
end
How can I get activity_notification to accept the username attribute, in place of the user_id?
UPDATE:
I changed the link_to method to
<%= link_to 'Notifications' user_notifications_path(current_user.id) %> and it works.
You probably have to user user.friendly_id or however, you have declared it to your model instead of user.id. This seems to the issue
I'm having trouble with my Rails 4 app.
I'm trying to follow this tutorial https://coderwall.com/p/rqjjca/creating-a-scoped-invitation-system-for-rails with some modifications.
The tutorial skips over a few steps that are considered by the writer to be too easy to bother with - I think that's where I'm getting stuck.
I have models for profile, project, team and user.
The associations are:
Profile.rb
has_many :teams, foreign_key: "team_mate_id"
has_many :team_projects, through: :teams, source: :project
has_many :invitations, :class_name => "Invite", :foreign_key => 'recipient_id'
has_many :sent_invites, :class_name => "Invite", :foreign_key => 'sender_id'
Project.rb
belongs_to :profile
has_one :team
has_many :team_mates, through: :team
has_many :invites
Team.rb
belongs_to :project
belongs_to :team_mate, class_name: "Profile"
Invite.rb
belongs_to :project
belongs_to :sender, :class_name => 'Profile'
belongs_to :recipient, :class_name => 'Profile'
In my routes, I have:
resources :invites
resources :teams
resources :profiles, only: [:show, :edit, :update, :destroy]
resources :projects do
member do
put "invite_team_mates" => "projects/invite_team_mates", as: :invitation
end
In my projects views folder, I have a partial with the invite form:
<%= form_for #invite , :url => invites_path do |f| %>
<%= f.hidden_field :project_id, :value => #invite.project_id %>
<%= f.label :email %>
<%= f.email_field :email %>
<%= f.submit 'Send' %>
<% end %>
I have also tried this as a general file called invite_team_mates.html.erb inside the project views folder and made a matching action for it in the projects controller, which has the action below: (with the route shown above for that specific action).
def invite_team_mate
project = Project.find(params[:id])
authorize #project
end
I'm also not sure if I have to change the opening line of form_for #invite should be something to do with #project.invite. Im not sure.
I also have an invites controller with:
class InvitesController < ApplicationController
def new
#invite = Invite.new
end
def create
#invite = Invite.new(invite_params)
#invite.sender_id = current_user.profile.id
if #invite.save
#if the user already exists
if #invite.recipient != nil
#send existing user email invitation to join project team
InviteMailer.existing_user_invite(#invite).deliver
#Add the user to the user group - inivte rsvp pending
#invite.recipient.project.push(#invite.project)
else
#send new user email invitation to join as a general user as well as join this project team
InviteMailer.new_user_invite(#invite, new_user_registration_path(:invite_token => #invite.token)).deliver
end
else
# oh no, creating an new invitation failed
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_invite
#invite = Invite.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def invite_params
params[:invite].permit(:email)
end
end
Im really stuck for how to hang all of this together.
My objective is to allow a user who creates a project to invite others to join the project team. I'm not getting far with this. When I try, to save all this and open the project, I get an error that says:
First argument in form cannot contain nil or be empty
The error highlights this line of the invites form partial:
<%= form_for #invite , :url => invites_path do |f| %>
When I try to change this line to use simple form syntax, as follows:
<%= simple_form_for(#invite, :url => invites_path) do |f| %>
I get an error that says:
undefined method `model_name' for nil:NilClass
I think that might have something to do with the form being for #invite when it is saved in the projects views folder.
Can anyone see what's gone wrong?
update - terminal lines
NoMethodError - undefined method `model_name' for nil:NilClass:
actionpack (4.2.4) lib/action_controller/model_naming.rb:9:in `model_name_from_record_or_class'
actionview (4.2.4) lib/action_view/record_identifier.rb:47:in `dom_class'
simple_form (3.2.0) lib/simple_form/action_view_extensions/form_helper.rb:62:in `simple_form_css_class'
simple_form (3.2.0) lib/simple_form/action_view_extensions/form_helper.rb:22:in `simple_form_for'
app/views/projects/_invite_team_mate.html.erb:6:in `_app_views_projects__invite_team_mate_html_erb___1258064784578419157_70357207009700'
actionview (4.2.4) lib/action_view/template.rb:145:in `block in render'
activesupport (4.2.4) lib/active_support/notifications.rb:166:in `instrument'
actionview (4.2.4) lib/action_view/template.rb:333:in `instrument'
actionview (4.2.4) lib/action_view/template.rb:143:in `render'
actionview (4.2.4) lib/action_view/renderer/partial_renderer.rb:339:in `render_partial'
actionview (4.2.4) lib/action_view/renderer/partial_renderer.rb:310:in `block in render'
actionview (4.2.4) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.4) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `instrument'
actionview (4.2.4) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
actionview (4.2.4) lib/action_view/renderer/partial_renderer.rb:309:in `render'
actionview (4.2.4) lib/action_view/renderer/renderer.rb:47:in `render_partial'
actionview (4.2.4) lib/action_view/renderer/renderer.rb:21:in `render'
actionview (4.2.4) lib/action_view/helpers/rendering_helper.rb:32:in `render'
haml (4.0.7) lib/haml/helpers/action_view_mods.rb:12:in `render_with_haml'
app/views/projects/show.html.erb:976:in `_app_views_projects_show_html_erb__3676206074319755518_70357179499400'
actionview (4.2.4) lib/action_view/template.rb:145:in `block in render'
activesupport (4.2.4) lib/active_support/notifications.rb:166:in `instrument'
actionview (4.2.4) lib/action_view/template.rb:333:in `instrument'
actionview (4.2.4) lib/action_view/template.rb:143:in `render'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (4.2.4) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.4) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `instrument'
actionview (4.2.4) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (4.2.4) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.2.4) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.2.4) lib/action_view/rendering.rb:100:in `_render_template'
actionpack (4.2.4) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.2.4) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (4.2.4) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.2.4) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
These lines go on and on - im not sure if this is what you mean by 'backtrace'
I'm trying to make a contact form work by following this tutorial, but I keep having the error : uninitialized constant ApplicationMailer after i submit the form.
the traces give the following informations:
app/mailers/message_mailer.rb:1:in <top (required)>'
app/controllers/messages_controller.rb:9:in create'
actionpack (4.2.5) lib/action_controller/metal/implicit_render.rb:4:in send_action'
actionpack (4.2.5) lib/abstract_controller/base.rb:198:in process_action'
actionpack (4.2.5) lib/action_controller/metal/rendering.rb:10:in process_action'
actionpack (4.2.5) lib/abstract_controller/callbacks.rb:20:in block in process_action'
activesupport (4.2.5) lib/active_support/callbacks.rb:117:in call'
activesupport (4.2.5) lib/active_support/callbacks.rb:117:in call'
activesupport (4.2.5) lib/active_support/callbacks.rb:555:in block (2 levels) in compile'
activesupport (4.2.5) lib/active_support/callbacks.rb:505:in call'
activesupport (4.2.5) lib/active_support/callbacks.rb:505:in call'
activesupport (4.2.5) lib/active_support/callbacks.rb:92:in __run_callbacks__'
activesupport (4.2.5) lib/active_support/callbacks.rb:778:in _run_process_action_callbacks'`
Here are the file i have :
controllers/messages_controller.rb
class MessagesController < ApplicationController
def new
#message = Message.new
end
def create
#message = Message.new(message_params)
if #message.valid?
MessageMailer.message_me(#message).deliver_now
redirect_to new_message_path, notice: "Thankyou for your message."
else
render :new
end
end
private
def message_params
params.require(:message).permit(:name, :email, :subject, :content)
end
end
models/message.rb
class Message
include ActiveModel::Model
attr_accessor :name, :email, :subject, :content
validates :name, :email, :subject, :content, presence: true
end
mailers/message_mailer.rb
class MessageMailer < ApplicationMailer
default :to => "jd.levarato#gmail.com"
def message_me(msg)
#msg = msg
mail from: #msg.email, subject: #msg.subject, body: #msg.content
end
end
You have to create ApplicationMailer class that inherits from ActionMailer::Base.
application_mailer.rb
class ApplicationMailer < ActionMailer::Base
default from: 'from#exmaple.com'
layout 'mailer'
end
Or you can simply inherit ActionMailer::Base to your MessageMailer
class MessageMailer < ActionMailer::Base
default :to => "jd.levarato#gmail.com"
def message_me(msg)
#msg = msg
mail from: #msg.email, subject: #msg.subject, body: #msg.content
end
end
I have the following relationship in my models:
class ClientProfile < ActiveRecord::Base
has_many :client_folders
has_many :folders, through: :client_folders
accepts_nested_attributes_for :folders
end
class Folder < ActiveRecord::Base
has_many :client_folders
has_many :client_profiles, through: :client_folders
end
class ClientFolder < ActiveRecord::Base
belongs_to :client_profile
belongs_to :folder
end
I have the relationships built up in controller:
#client_profile = ClientProfile.new
2.times do |i|
#folder = Folder.new(folder_name: "folder #{i}")
#client_profile.folders << #folder
end
I have the following fields_for associations created in view:
<%= form_for #client_profile do |f| %>
...
<%= f.fields_for :folders do |folder_builder| %>
<%= folder_builder.text_field :some_column %>
...
<% end %>
<% end %>
And the create action:
def create
#client_profile = ClientProfile.new client_profile_params
if #client_profile.save
...
else
...
end
end
When I save the association, it does create the client_profile as well as the two folders, and the join model ClientFolder is correctly created twice. However in both ClientFolders created, it only has the folder_id filled in. The client_profile_id is left null.
One solution I tried is adding the following to client_profile to ensure it saves the join model relation correctly:
def folders_attributes=(params)
if params["0"][:id].nil?
params.values.each do |v|
f = Folder.new v
self.folders << f
end
end
end
But this raises the following exception when saving:
NoMethodError - undefined method `each' for #<ClientFolder:0x007fd364743d78>:
activemodel (4.1.5) lib/active_model/attribute_methods.rb:435:in `method_missing'
activerecord (4.1.5) lib/active_record/attribute_methods.rb:208:in `method_missing'
activerecord (4.1.5) lib/active_record/autosave_association.rb:349:in `save_collection_association'
activerecord (4.1.5) lib/active_record/autosave_association.rb:186:in `block in add_autosave_association_callbacks'
activerecord (4.1.5) lib/active_record/autosave_association.rb:157:in `instance_eval'
activerecord (4.1.5) lib/active_record/autosave_association.rb:157:in `block in define_non_cyclic_method'
activesupport (4.1.5) lib/active_support/callbacks.rb:424:in `block in make_lambda'
activesupport (4.1.5) lib/active_support/callbacks.rb:221:in `call'
activesupport (4.1.5) lib/active_support/callbacks.rb:221:in `block in halting_and_conditional'
activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.5) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.5) lib/active_support/callbacks.rb:86:in `run_callbacks'
activerecord (4.1.5) lib/active_record/callbacks.rb:306:in `_create_record'
activerecord (4.1.5) lib/active_record/timestamp.rb:57:in `_create_record'
activerecord (4.1.5) lib/active_record/persistence.rb:482:in `create_or_update'
activerecord (4.1.5) lib/active_record/callbacks.rb:302:in `block in create_or_update'
activesupport (4.1.5) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.5) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.5) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.5) lib/active_support/callbacks.rb:86:in `run_callbacks'
activerecord (4.1.5) lib/active_record/callbacks.rb:302:in `create_or_update'
activerecord (4.1.5) lib/active_record/persistence.rb:103:in `save'
activerecord (4.1.5) lib/active_record/validations.rb:51:in `save'
activerecord (4.1.5) lib/active_record/attribute_methods/dirty.rb:21:in `save'
activerecord (4.1.5) lib/active_record/transactions.rb:268:in `block (2 levels) in save'
activerecord (4.1.5) lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
activerecord (4.1.5) lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'
activerecord (4.1.5) lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'
activerecord (4.1.5) lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'
activerecord (4.1.5) lib/active_record/transactions.rb:208:in `transaction'
activerecord (4.1.5) lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
activerecord (4.1.5) lib/active_record/transactions.rb:268:in `block in save'
Someone else recommended to add the join model association:
accepts_nested_attributes_for :client_folders
But it doesn't make sense to do that, since I am not using client_folders at all in the form. When I use fields_for :folders in form, it should be intelligent enough to save the join model properly in create.
How can I resolve this issue?
I discovered the problem.
I had defined the relation twice in the model:
has_many :client_folders
has_one :client_folders, :class_name => 'ClientFolder', :foreign_key => :folder_id
When I removed that has_one, everything worked accordingly.
I have the following two models:
# app/models/customer.rb
class Customer < ActiveRecord::Base
has_paper_trail
serialize :mail_opt_out, Set
before_create :generate_token
has_many :wallets
has_many :tickets, through: :wallets
...
# We have a special seeded customer with id -1 that we don't want changing
def readonly?
persisted? && id < 0
end
end
# app/models/ticket.rb
class Ticket < ActiveRecord::Base
include SparkCast
has_paper_trail
belongs_to :price
belongs_to :basket
belongs_to :occurrence
has_one :event, through: :occurrence
has_one :wallet, through: :basket
has_one :basket_type, through: :basket
has_one :customer, through: :basket
delegate :id, to: :customer, allow_nil: true
...
def admit
ensure_can_admit
self.state = 'admitted'
self.save!
end
cast_on :admit, room: :admittance
def as_cast
{
id: id,
customer_id: customer_id
}
end
end
The relevant association is a little convoluted, but is customers -> wallets -> baskets -> tickets.
When I call admit on an instance of a ticket that belongs to our customer with id -1, (which is read only) I get an ActiveRecord::ReadOnlyRecord exception.
I'm confused as to what is causing this, as neither ticket nor customer have any before_update callbacks. If I change
has_one :customer, through: :basket
to
delegate :customer, to: :basket
then everything is fine. Something seems to be either trying to update the customer, or at least checking if it is readonly.
I've done a bit of stepping through the save procedure using byebug, but haven't been able to find anything useful.
What is likely to be checking if an associated model is readonly, and how do I get around this? Is using delegate the best option here?
Edited to add:
Also including SparkCast, which I had omitted previously. Removing the cast_on method from my ticket model is fixing the problem.
# app/models/concerns/spark_cast.rb
module SparkCast
extend ActiveSupport::Concern
module ClassMethods
def cast_on(*args)
# Options are the last argument.
options = args.pop
room = options[:room]
args.each do |operation|
class_eval do
begin
alias_method "#{operation}_without_cast", operation
define_method operation do |*args|
cast_hash = as_cast
...
send("#{operation}_without_cast", *args)
cast(room, operation, cast_hash)
end
rescue NameError => e
raise "#{e.name} has not been defined yet. Include cast_on after method definition"
end
end
end
end
end
end
Backtrace:
- activerecord (4.1.0) lib/active_record/persistence.rb:481:in `create_or_update'
- activerecord (4.1.0) lib/active_record/callbacks.rb:302:in `block in create_or_update'
- activesupport (4.1.0) lib/active_support/callbacks.rb:113:in `call'
- activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.0) lib/active_support/callbacks.rb:86:in `run_callbacks'
- activerecord (4.1.0) lib/active_record/callbacks.rb:302:in `create_or_update'
- activerecord (4.1.0) lib/active_record/persistence.rb:103:in `save'
- activerecord (4.1.0) lib/active_record/validations.rb:51:in `save'
- activerecord (4.1.0) lib/active_record/attribute_methods/dirty.rb:21:in `save'
- activerecord (4.1.0) lib/active_record/transactions.rb:268:in `block (2 levels) in save'
- activerecord (4.1.0) lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
- activerecord (4.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `transaction'
- activerecord (4.1.0) lib/active_record/transactions.rb:208:in `transaction'
- activerecord (4.1.0) lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
- activerecord (4.1.0) lib/active_record/transactions.rb:268:in `block in save'
- activerecord (4.1.0) lib/active_record/transactions.rb:283:in `rollback_active_record_state!'
- activerecord (4.1.0) lib/active_record/transactions.rb:267:in `save'
- activerecord (4.1.0) lib/active_record/autosave_association.rb:393:in `save_has_one_association'
- activerecord (4.1.0) lib/active_record/autosave_association.rb:188:in `block in add_autosave_association_callbacks'
- activesupport (4.1.0) lib/active_support/callbacks.rb:424:in `block in make_lambda'
- activesupport (4.1.0) lib/active_support/callbacks.rb:221:in `block in halting_and_conditional'
- activesupport (4.1.0) lib/active_support/callbacks.rb:86:in `run_callbacks'
- activerecord (4.1.0) lib/active_record/callbacks.rb:310:in `update_record'
- activerecord (4.1.0) lib/active_record/timestamp.rb:70:in `update_record'
- activerecord (4.1.0) lib/active_record/persistence.rb:482:in `create_or_update'
- activerecord (4.1.0) lib/active_record/callbacks.rb:302:in `block in create_or_update'
- activesupport (4.1.0) lib/active_support/callbacks.rb:113:in `call'
- activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `block in halting'
- activesupport (4.1.0) lib/active_support/callbacks.rb:86:in `run_callbacks'
- activerecord (4.1.0) lib/active_record/callbacks.rb:302:in `create_or_update'
- activerecord (4.1.0) lib/active_record/persistence.rb:125:in `save!'
- activerecord (4.1.0) lib/active_record/validations.rb:57:in `save!'
- activerecord (4.1.0) lib/active_record/attribute_methods/dirty.rb:29:in `save!'
- activerecord (4.1.0) lib/active_record/transactions.rb:273:in `block in save!'
- activerecord (4.1.0) lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
- activerecord (4.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `block in transaction'
- activerecord (4.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:219:in `within_new_transaction'
- activerecord (4.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
- activerecord (4.1.0) lib/active_record/transactions.rb:208:in `transaction'
- activerecord (4.1.0) lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
- activerecord (4.1.0) lib/active_record/transactions.rb:273:in `save!'
- () home/hayden/development/SparkSeat/api/app/models/ticket.rb:79:in `admit'