I have a line in my routes.rb to map my Album model as a resource:
map.resources :albums
However, using Datamapper in place of ActiveRecord in Rails, why would this line:
format.html { redirect_to(@album) }
cause a redirect to:
albums/%23<Album:0x72d452c>
instead of:
albums/1
In case further context is needed, my full create method from the Controller is listed here:
def create
@album = Album.new(params[:album])
respond_to do |format|
if @album.save
flash[:notice] = 'Album was successfully created.'
format.html { redirect_to(@album) }
format.xml { render :xml => @album, :status => :created, :location => @album }
else
format.html { render :action => "new" }
format.xml { render :xml => @album.errors, :status => :unprocessable_entity }
end
end
end
As is convention, this method is invoked as a result of a form submission from my 'new' method in the new.html.erb:
<h1>New album</h1>
<% form_for(@album) do |f| %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.label :description %><br />
<%= f.text_field :description %>
</p>
<p>
<%= f.label :genre %><br />
<%= f.text_field :genre %>
</p>
<p>
<%= f.label :country %><br />
<%= f.text_field :country %>
</p>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
<%= link_to 'Back', albums_path %>