Find id of newly created object

Hi there,

I’m kind of a newbie, so pardon me if this is obvious

I’m developing an app that has to accept creation of records from http
requests such as
http://my.domain.com/in/[email protected]=myName

So I have this route :
map.connect ‘/in’, action: ‘incoming’

and this action in the controller (mostly borrowed from scaffold)

def incoming
@message = Message.new
@message.text = params[:text]
@message.sender = params[:alias]
respond_to do |format|
if @message.save
format.html # incoming.html.erb
format.xml { render :xml => @message }
end
end
end

and a small view to acknowledge incoming message
incoming.html.erb

Incoming message #<% @message.id %> from <%= @message.sender %>

Problem is I never get back the @message.id.

I always get something like:

Incoming message # from myName

Any thoughts ?

Thanks,

Christophe

On Fri, Mar 26, 2010 at 7:44 AM, Christophe D.
[email protected] wrote:

and a small view to acknowledge incoming message
incoming.html.erb

Incoming message #<% @message.id %> from <%= @message.sender %>

Problem is I never get back the @message.id.

Copy/paste error, or are you missing an ‘=’ sign there?
#<%= @message.id %>


Hassan S. ------------------------ [email protected]
twitter: @hassan

Thanks,

I’m so stupid…
Can’t understand how I missed that

Christophe
Le 26 mars 2010 à 16:01, Hassan S. a écrit :

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs