[Rails] Saving parent record before child

2009-04-17 Thread josh.rach...@gmail.com

I am on Rails 2.2 and want to save an artist object with a child
attribute called artist_mood_concepts.  I can update fine but when I
do an @artist.save, it gives me an error about saving the parent
before the child (which makes perfect sense).  What is the easiest way
to solve the problem?  after_update?

Thanks,

Josh

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Unknown Action error while updating record

2009-04-15 Thread josh.rach...@gmail.com

I understand other people have had trouble using :action => 'update'
with form_tag... but I haven't figured it out yet... here is my
declaration of the form:

<% form_tag :action => 'update', :html => {:method => "put"} do %>

I tried just using <% form_tag :action => 'update' % do>, along with
other structures... It just says UNKNOWN ACTION since it is trying to
use the id as the action...

Can anyone help??

I would like to keep it as a form_tag though. Thanks in advance for
the help

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: rails + validations -- place them in application.rb?

2009-04-07 Thread josh.rach...@gmail.com

One more thing... I think I made the mistake of making the "set of
validations" sound like validate_xxx_of type functions... if I am
needing the following functions to be global (this is some old code,
but just for example) could i just add them to application_helper?


  def validate_duplicate_artist(artist)
# Query DB for the given artist
@result = Artist.find(:first, :conditions => [ "name = ?",
artist])
# If no matches, then go ahead and add
if @result.nil?
# calls parser function to clean up the artist to a general
format
artist_parsed = validate_artist_parser(artist)
# pp artist_parsed
Artist.all.each do |artist|
# calls parser function to clean up the artist from db to the
general format
artist_db = validate_artist_parser(artist.name)
if artist_parsed == artist_db
# if the db artist and crawled artist find a match, 
then return
the id and status of that artist
return {:id => artist.id, :status => artist.status}
end
end
return {:id => 0, :status => "dup"}
 else
return {:id => @result.id, :status => @result.status}
 end
  end

  def validate_artist_parser(artist)
a = artist.downcase
a.gsub!(/ & /, " ")
a.gsub!(/ and /, " ")
a.gsub!(/ an /, " ")
a.gsub!(/ the /, " ")
a.gsub!(/ a /, " ")
a.gsub!(/\./, "")
a.gsub!(/,/, "")
a.gsub!(/'/, "")
a.gsub!(/-/, "")
a.gsub!(/!/, "")
a.gsub!(/’/, "")
a.gsub!(/ /, "")
return a.downcase
  end

These are validations that need to be accessed from an admin tool and
a crawler_controller... It just looks like adding to the active record
validation.rb file might not be the right place.  Maybe I'm wrong?



On Apr 6, 12:42 pm, "josh.rach...@gmail.com" 
wrote:
> I need to put a set of validations in a place that can be accessed by
> multiple controllers... do I just place them in application.rb?
>
> Thanks,
>
> Josh

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] rails + validations -- place them in application.rb?

2009-04-06 Thread josh.rach...@gmail.com

I need to put a set of validations in a place that can be accessed by
multiple controllers... do I just place them in application.rb?

Thanks,

Josh

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] datetime_select issues

2009-04-01 Thread josh.rach...@gmail.com

I tried using this to build a datetime text box area:  select_datetime
(date = Time.now, :order => [:year, :month, :day])

This just returns a hash will the year, month, day, hour, minute.

I also tried using datetime_select to do the same thing, but cant
figure out how to capture the value of the input. Is there an easier
way to do this??

Thanks,

Josh

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---