rubyonrailsin

A Ruby and Rails talk

Tuesday, March 16, 2010


Re: [Rails] Re: SQL result to String conversion

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

On 16 March 2010 19:33, Rohit Shinde <lists@ruby-forum.com> wrote:
> Can you please advice me a way to extract just the name from there?

This will give you what you want:
<%= User.find(:all, :select => 'name', :conditions => ["id = ?", 1]).name %>

...but there are so many poor and bad-practice things going on in that
line.... It's great that you've got as far as you have - to have
working models and views - but there's some large steps you need to
take that are covered well in lots of online references and in any of
the books that deal with getting started with Ruby/Rails.
I'd suggest visiting them and getting much more comfortable with the
basics to help you to get as quickly as possible to a position where
you will be able to produce useful code.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive