Ruby on Rails Monday, May 26, 2014

This could be written as this:

@dict = Dict.where(:dictname => dict_name).first

It will either return a record, or nil.

Walter

On May 26, 2014, at 8:38 AM, Ronald Fischer wrote:

> if Dict.exists?(:dictname => dict_name)
> logger.debug('found dictionary with name '+dict_name)
> dictid=Dict.where(:dictname => dict_name).select('id').first.id
> logger.debug('dictid='+dictid.inspect)
> @dict=Dict.find(dictid)

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7EADD849-5745-45BC-9B4E-E411FD6B3339%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment