I need to do an html delete if the record isn’t saved, so in Rails 2,
all I had to do was:
<% if person_form.object.new_record? %>
<%= link_to_function “Delete”, “delete_row()” %>
<% else %>
…
object doesn’t seem to be there, and rails 3 seems angry about the
fields_for that defines person_form in Rails 2.
I’m trying to do this in Rails 3 and having no luck… Please help
Thanks
Bob S. [email protected]
Both ActionView::Helpers::FormBuilder#object() and
ActiveRecord::Persistence#new_record?() exist in rails 3. Here is how
“Ruby on Rails 3 Tutorial” uses them:
<%= form_for(@user) do |f| %>
<%= render ‘some/partial’, :object => f.object %>
Then a local variable named ‘object’ is available in the partial and it
is equal to @user (at least that is the way things appear to work).
class User < ActiveRecordBase
…
…
def some_action
if new_record?
#do something
end
end
and rails 3 seems angry about the
fields_for that defines person_form in Rails 2
You should post your code.