[Ruby] Active Record and Array error
Victor Cosby
victorcosby at gmail.com
Thu Jun 21 17:35:24 PDT 2007
Aha, now I see what you're doing.
Ruby will return the last value from the method so you don't need the
temporary owners variable. And since you're in Rails you can use
blank?
def owners
[self.Owner1, self.Owner2, self.Owner3].reject { |o| o.blank? }
end
Victor
On 6/21/07, Neil Moomey <neil at motznik.com> wrote:
> Actually, the Owner1= was just added for debugging purposes. I can add any
> labels in my view if needed. My final code in my Model looks like:
>
> def owners
> owners = [self.Owner1, self.Owner2, self.Owner3].reject { |o| o.nil? or
> o.strip.empty? }
> end
>
> and my view:
>
> <% @anchorage_prop.owners.each do |q| %>
> <%= h(q)%></br>
> <% end %>
>
> Neil
More information about the Ruby
mailing list