Note that there are some explanatory texts on larger screens.

plurals
  1. PORails 100% newb issue - send() method
    primarykey
    data
    text
    <p>Could someone please help me to understand what the 'send()' method listed below is used for? The code below, when I am reading it, makes no sense what purpose it's serving.</p> <p>It's a Rails app using Ruby 1.8.7 with Rails 1.2.3. Please don't harp on me about upgrading, it's a client's environment, so I don't have that sort of leisure.</p> <p>Needless to say though, the statement I am referring to is like this;</p> <pre><code>def do_schedule @performance = Performance.new(params[:performance]) @performer = Performer.find(params[:performer_id]) selected_track = params[:selected_track] if FileTest.exists?(File.expand_path(@performer.photo)) @performance.photo = File.open(File.expand_path(@performer.photo)) end @performance.audio = File.open(File.expand_path(@performer.send(selected_track))) if @performance.save flash[:notice] = 'Performer scheduled.' redirect_to :controller =&gt; :performer, :action =&gt; :index else render :action =&gt; 'schedule' end end </code></pre> <blockquote> <p>Performer Model</p> </blockquote> <pre><code>class Performer &lt; ActiveRecord::Base file_column :audio_one file_column :audio_two file_column :audio_three file_column :photo belongs_to :festival validates_presence_of :name, :first_name, :last_name, :address, :city, :state, :zip, :daytime_phone, :availability, :stages validates_format_of :email, :with =&gt; /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i validates_confirmation_of :email validates_presence_of :audio_one, :audio_two, :audio_three, :photo, :if =&gt; :submitted after_create :salt_access_key serialize :availability serialize :stages attr_accessor :other_type_of_music before_save :set_other_type def set_other_type if type_of_music == 'Other' self.type_of_music = "Other - #{other_type_of_music}" unless other_type_of_music.blank? end end def salt_access_key update_attribute(:access_key, Digest::SHA1.hexdigest("--#{self.id}--#{self.name}--#{self.festival.year}")) end def preferred_stages stages = [] festival = Festival.find(self.festival_id.to_i) self.stages.collect { | key, value | id = key.gsub(/[\D]/, '').to_i if id &gt; 0 stages &lt;&lt; festival.performance_stages.find(id).name end } return stages end end </code></pre> <p>The controller that this is contained in is Performance. I have been scouring Google trying to figure out what purpose that '@performer.send(selected_track)' is actually doing, but feel like I'm rowing against a whirlpool.</p> <p>Can someone please help me make better sense out of this?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload