similar to: methods in models dont work for views?

Displaying 20 results from an estimated 10000 matches similar to: "methods in models dont work for views?"

2006 Jul 30
2
options_from_collection_for_select & multiple columns
I have a table with first_name and last_name, and wan''t to populate a drop-down with the id and the person''s name consisting of the first and last names concatenated together. Can''t figure out how to tell options_from_collection_for_select to do that. Any ideas? I basically need to do something like: <%= options_from_collection_for_select @media_creators,
2005 Mar 08
1
Adding to model (newbie)
Sorry if this is a really lame question, I''m sure it''s something fairly obvious, but I just can''t see it at the moment... I''m trying to add something simple to the model for a project management/todo list/thing. The DB has ''first_name'' and ''last_name'', and I''d like to have "full_name" available. So -
2006 Jan 25
7
join fields for list views
I am sitting with the Agile book on my desk and scratching my head at the discussion on aggregation - perhaps that isn''t what I need. I have a db called clients. fields include - first_name middle_initial last_name I want to combine them all into one name element in a list view. I can add/edit the fields separately but in the list view, I only want the one combo field. Is there a
2007 Dec 07
4
capitalizing an attribute - view, controller, or model?
The users will enter students names on forms. How do I intercept the first and last names and have them stored capitalized when the user inputs them in lower case? Do I mess with the form html, skipping form_for helpers and using conditional clauses in the view? Do I need to separate out the individual attribute and update it separately in the controller actions that save/updates the
2010 Oct 05
2
Is it possible to query on virtual attributes?
I have a Person model with attributes first_name and last_name. I want to implement autocomplete search that looks that the entire name. Hence I have a method: def full_name self.first_name + " " + self.last_name end Is it possible for me to query on full_name and have rails match the first_name and last_name fields? I currently receive this error when I try, because full_name
2006 Jan 19
2
Simple Ferret Questions
I am trying to use Ferret for searching for users based on first and last name. In my index, I am adding the first_name, last_name, and a full_name which is basically "#{first_name} #{last_name}". I am searching the index using something like the following query: INDEX.search_each(%Q/first_name:#{query}* OR last_name:#{query}* OR full_name:#{query}*/) do |doc, score| The problem I am
2007 May 27
3
[NoMethodError] simple problem
I think this test should pass but it doesn''t 1) NoMethodError in ''Person should return full name'' undefined method `full_name?'' for #<Person:0x3567964> ./spec/models/person_spec.rb:43: describe Person do it "should return full name" do person = Person.new person.should be_full_name end end class Person < ActiveRecord::Base def
2007 Dec 04
5
when to save, session reflect saves?
I am trying to clean up unnecessary lines (even as I hack my way forward adding more garbage) I have two questions on lines I have trying to keep the database and session info reflecting changes: def associate_pupil_to_teacher @teacher = session[:teacher] @pupil = Pupil.find(params[:id]) @teacher.pupils << @pupil @teacher.save #Q1 session[:teacher] = @teacher #Q2 end #Q1 do i
2006 Mar 16
6
How to have multiple fields appear in collection_select?
I have a table of employees with the fields "last_name" and "first_name". I would like to populate a collection select so that what the user sees in the drop-down is "Last Name, First Name". So far, the only way I have figured out to do this is by using "find_by_sql" in my model, like so: @employees.find_by_sql("SELECT id, concat(last_name,
2009 Sep 08
1
How to validate_uniqueness_of the joint of two attributes?
Hi, I have a form that asks users to put in their :first_name and :last_name. How do I validate that their full_name (first_name + last_name) is unique? Thanks! Nguyen Anh Hung Assistant Project Manager/ Consultant/ Business Analyst Tech Propulsion Labs Mobile: +84987 005 477 Twitter: http://www.twitter.com/anhhung Blog: http://www.fresco20.com Skype: anhhung.n | Yahoo: hero.tuxer | Gtalk:
2006 Jul 14
1
creating a computed column with activerecord for to_xml
Hi. I have a question about activerecord, computed columns and to_xml. I have a simple model called person that has a first_name and a last_name field (and thus a first_name and last_name field in the Person table). When I :find a model and call to_xml, I would like the result to not only send back first name and last name as xml but also add an additional attribute called full_name that is
2005 Feb 05
4
Creating collections
I''m trying to create a form where a collection is created, using the example from the Rails 0.9.5 weblog posting: http://weblog.rubyonrails.com/archives/2005/01/26/rails-095-a-world-of- fixes-and-tweaks/ I''m having a bit of trouble. The controller currently looks like this: class StudentController < ApplicationController def new render_text @params.inspect
2006 Jan 20
4
Questions about Searching
Hi, I have some questions about searching with Ferret. I have a user index with first_name, last_name and full_name (which is just first plus last with a space). Here are a couple of questions: 1) If I store the fields tokenized, it appears as though queries are case-insensitive. However, for untokenized, the query is case-sensitive. How can I make the untokenized searches case-insensitive?
2005 Dec 30
1
NewbieQ concatenating name in options_from_collection_for_select
Hi, A real dumb one :~/ How do you concatenate a first_name, last_name as the text method for OFCFS? Damned if I can do it without error. Is it in the original select for the collection? Eric.
2007 Jul 14
1
performance bottleneck
I have got my database in Mysql. I used ferret to index a table with 10 million rows. On limiting the selection of data to 1000 initial retrieval, it takes 200 seconds but for the whole table it took more than four hours and after which i had to close my indexing application. I used the StandardAnalyser for it. There is no problem from the database side as retrieval of all the data in the table
2006 Jan 08
1
Options_from_collection_for_select -> Multiple fields in display
The following code shows a list of the users, with username being each person''s initials (mine would be DM). &lt;%= options_from_collection_for_select @users,"id","username" %&gt; However, I''d like to have the display of the SELECT box be "DM - Dylan Markow" instead of "DM." Is this possible using
2007 Oct 13
4
Chapter 9
Hello, I''m currently stunk on this issue for few days and I do not know how to get it fixed. The system always raises this error message : order is closed and here is my order.rb: class Order < ActiveRecord::Base include ActiveMerchant::Billing before_validation :set_status attr_protected :id, :customer_ip, :status, :error_message, :updated_at, :created_at attr_accessor
2005 Mar 08
29
Interrupt levels
I''m tracking performance on the machine I installed yesterday. mutt running on one Xen instance, accessing via imap to another instance, accessing via nfs the maildir in another instances, seems little laggy when moving up and down the message index list. Network latency seems low < 30ms on average. So I was tracking vmstat. On the mutt instances is seems reasonable: [nic@shell:~]
2007 Nov 06
2
Why is this view spec failing?
I can''t figure out why I am getting a failure. It renders out fine in the browser. <h1>New member</h1> <%= error_messages_for :member %> <% form_for(:member, :url => members_path) do |f| %> <fieldset> <legend>Member Info</legend> <p><label for="member[first_name]">First Name:</label> <%=
2005 Dec 22
7
Ruby on Rails and lookup tables
Hi, I''m a newbie on both Ruby and Ruby on Rails, and I''m struggling with my first app. I have a table with a column called "employee_id" which is a foreing key associating it with the "employees" table. I have populated both tables. When I run "ruby script/generate scaffold <model name> <controller>" it generates a web page with all