I have two questions (dev env - macosx mountain lion, Rails4, Ruby 2.0.0)
1.What gems do you recommend for generating pdf’s and uploading documents, photo’s, etc…
Usage - After the user completes a series of forms, they should get a email with a pdf attachment that includes details of their transaction. Also, the user should be able to upload their avatar and other required documentations. I am guessing it will be paperclip and prawn, but maybe there is something new?
- I have a twitter bootstrap modal working correctly except the modal closes when a validation fails, how I can prevent this action before the redirect takes place? I don’t want the new or create actions as the user will only have the ability to update information already in the database.
Here is what I have so far…
def update
if @athlete.update(athletes_params)
redirect_to @athlete, notice: "Your information was updated successfully"
mixpanel.track 'User Updated', {
:distinct_id => @user.id,
:time => @user.updated_at
}
mixpanel.set ({ :distinct_id => @user.id, :email => @user.email, :first_name => @user.first_name, :last_name => @user.last_name})
else
flash[:error] = "Opps! Sorry #{@user.first_name} you forgot something on the, please complete all the required fields"
@sport = @user.athlete
render :show
end
end
Model -
class Athlete < ActiveRecord::Base
extend FriendlyId
#friendly_id :name, use: :slugged
belongs_to :user, dependent: :destroy
has_many :sports
accepts_nested_attributes_for :sports
validates_inclusion_of :ncaa, :in => [true], :message => 'You must certify'
validates_presence_of :campus_box, :message => 'Please enter your campus box'
def parents_name
"#{parent_guardian_1_first} #{parent_guardian_1_last}" " & " "#{parent_guardian_2_first} #{parent_guardian_2_last}"
end
end
Modal - The form submit action
<%= link_to 'Open NCAA Student-Athlete Statement', ncaa_form_athlete_path(@athlete), :target => "_blank" %>
<%= simple_form_for @athlete, :url => athlete_path(@athlete), :validate => true, :html => { :method => :put, :multipart => true, :class => 'form-horizontal' } do |f| %>
Thanks for the help!