Displaying 20 results from an estimated 7000 matches similar to: "capitalizing an attribute - view, controller, or model?"
2007 Nov 28
5
methods in models dont work for views?
This question is more towards understanding how things work rather than
trying to just get something to work.
I have something like this in my user model.
def full_name
first_name + " " + last_name
end
This works find if I use it for display values in a
collection_for_select.
options_from_collection_for_select( @users, :id, :full_name)
It displays the full name in the
2013 Nov 06
6
Feature: make capitalization optional in *humanize*
According to the documentation<http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-humanize> of
ActiveSupport::Inflector:
*humanize*(lower_case_and_underscored_word)
Capitalizes the first word and turns underscores into spaces and strips
a trailing “_id”, if any.
* Example: humanize("employee_salary") # => "Employee salary"*
I would
2009 Mar 23
1
Capitalizing first letter of word or phrase
I managed to find toupper() which translates all letters to uppercase.
Is there a function to capitalize only the first letter of word or
phrase ?
Thanks
2006 Aug 07
8
Login form question
I''m using Rails Recipes to create a login form but instead of username
and password, my setup is firstname, lastname, password.
I seemed to be gramatically challenged and not sure how to set up the
parameter list. Can anyone offer up a suggestion.
The book shows the method starting like:
if request.post?
user = User.find(:first, :conditions => [''username = ?'' ,
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> <%=
2006 Aug 18
2
How do I sort the drop-down list?
I''ve added a drop-down list of first and last names of borrowers to a
form. How do I sort them by LastName, FirstName in the drop-down?
I''m using code based on the cookbook example:
<select name="borrower[borrower_id]">
<% @borrowers.each do |borrower| %>
<option value="<%= borrower.id %>">
<%= borrower.FirstName <<
2009 Mar 13
2
ruby capitalizing singular version of route
Hi All,
I''ve searched on this topic and can''t seem to find anyone results saying
others have had the same problem, so hope someone here can help.
if in routes, I map addresses:
map.resources :addresses
If get the following routes:
addresses
new_Address
edit_Address
Note that the singular routes (new, edit) are capitalized.
to prove the issue, in console, I can type:
>>
2006 Feb 26
3
simplify
Trying to use Eric''s help and Amy Hoy''s page of playing with
auto_complete and decided that the script/console is the place to
rapidly test.
I have this feeling that CONCAT isn''t working for postgresql...
c = find_by_sql(SELECT * FROM clients WHERE CONCAT
(first_name,middle_initial,last_name) = "johnadams")
^
(irb):61:
2006 Jan 05
7
HOWTO: Combine fields from 2 two tables in 1 object
Hi all,
For a dropdownlist (showing "Company - FirstName Lastname'') I want to fill an
object @project_contacts with "Name" from table Companies and "Firstname" and
"Lastname" from table contacts. Any idea?
Regards,
Gerard.
--
"Who cares if it doesn''t do anything? It was made with our new
Triple-Iso-Bifurcated-Krypton-Gate-MOS
2011 Dec 06
1
mongodb topic in rails
Hi
I use mongoid for rails application
and I try to do
@users = User.where("first_name = ? OR last_name = ? OR type = ?",
firstname, lastname, usertype)
but I am getting error
but when i put:
@users = User.where(:first_name => firstname, :last_name => lastname,
:type => usertype).all
the program run successfully
but i need OR to execute in mongodb
Also I need sql LIKE to
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?
2006 Mar 15
4
[NQ] How to set an initial FK for a new item of something?
Hi all,
running into a little problem here. I''ve a list of things
with a "New thing" link beneath it. When you click that link,
obviously, a new thing shall be created. Now, that works pretty
fine for things that don''t have foreign keys, but for things that
do it crashes, since there is not yet a thing.other_thing.name
available.
I suspect you can somewhere in
2006 Jan 10
8
Noob: Child records not saved
Hi all,
happily coding along, but it seems a belongs_to record is not saved.
# Create some stuff
def create_project
@contact = Contact.new
@project = Project.new(@params[''project''])
@project_contact = ProjectContact.new(@params[''collect''])
@project.project_contact = @project_contact
contact =
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,
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
2011 Jul 14
1
Correct behavior of Hmisc::capitalize()?
Hi,
from example(capitalize) of the Hmisc package (v 0.8.3) you get:
> capitalize(c("Hello", "bob", "daN"))
[1] "Hello" "Bob" "daN"
Is that "daN" correct?
If so, then this behavior that only *all lowercase strings*, which the
code indicates, will be capitalized is not documented.
> Hmisc::capitalize
function
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 10
15
Scaffolding for pre-existing database table in 2.0.1
Hi,
first of all I will apologize in advance for my presumably noobish
question, but I''m only starting to learn Rails and am a little
confused with all the changes in 2.0.1. There are as good as no
tutorials out yet and the 2 or 3 screencasts I''ve seen deal with the
creation of both the app and the database.
Now my problem is that I already have a database with a fair amount of
2009 Jul 01
2
Nested Forms - how to displayed the attributes content ?
I have a User model
class User < ActiveRecord::Base
has_one :account
accepts_nested_attributes_for :account, :allow_destroy => true
validates_associated :account
attr_accessible :account_attributes
is working fine, validating and updating both records (User and
Account), but I caanot display the value in the form when is updated,
ex: below the firstname is not displayed but
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