Displaying 20 results from an estimated 1000 matches similar to: "searching on foreing keys"
2006 Aug 02
2
Ajax_Scaffold display from link table
Hi,
Ive followed the pets/people ajax_scaffold example without any problem.
I have a table documents and each document has a category. In the
documents table i have a field called category_id. So in the documents
grif i want to display the corresponding catgory name and when it comes
to adding a new category or editing the have a drop down list to select
from.
category.rb
require
2006 Feb 08
7
DRY methodology
because I am a grasshopper...
Now that I can sort my ''list''...is there a logical way of not repeating
myself to having essentially the same list view with multiple sorts?
i.e.
def list_cl
# ordered by clients last name
@placement_pages, @placements = paginate(
:placements,
:include => [:client],
:order_by =>
2005 Dec 31
3
Sort or Order a <Select> box.
Evening folks,
I''m new to RoR, and have found some very useful info on this site,
thanks.
I have a select box that I need to sort.
<select name="people[peoplekind_id]">
<% @peoplekinds.each do |peoplekind| %>
<option value="<%= peoplekind.id %>"
<%= '' selected'' if peoplekind.id == @people.peoplekind_id %>>
<%=
2006 Apr 03
2
Order By Number of Comments
Hi,
I am new to Ruby on Rails, so I apologise if this has been answered
elsewhere. I have had a look through the list but I can''t seem to find
what I am trying to do.
I have implemented the standard blog and comments app from the
screencast. However I am trying to extend the functionality.
I want to be able to display a list of posts and order them by the total
number of comments
2008 Jul 08
4
Conditional "link_to" helper function - AYUDAME POR FAVOR
Hello,
I need to write a function that will return a link only if the current
user is the owner. Here is my code...
1. application_helper.rb
2.
3. def link_to_if_owned(owner_id, anchor_text, where_to_go)
4. if current_user.id == owner_id # current user is owner
5. "#{link_to anchor_text, where_to_go}"
6. else
7. anchor
8. end
9. end
And
2007 Feb 25
1
Relationships question (?)
Hello there,
Im currently taking a Senior Design Course at my college. We are
developing an online document editor prototype with Rails.
I am not well-versed in Rails. As a matter of fact, we chose it for the
project in order to learn it.
The problem we have is the following:
We have a User model (id, username, password, email) and we have a
Document model (id, name, content, owner_id). A
2006 Apr 06
6
pagination question
i''ve figured out how to use the next and previous links with the
paginator class but now i''m trying to figure out how to display all the
page numbers in between. looking through the rails api, i found
paginator.each() but i''m not sure how to use it, or if that''s even what
i am looking for.
also, is there a way to limit the amount of pages like some sites
2008 Jun 13
6
Newbie question on has_many
I have two classes: a Widget and a User. The User has an id that is
referenced in two places on the Widget: owner_id and operator_id.
How should I structure that reference for has_many?
Thanks folks - I appreciate any help on this.
--David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails:
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 Jul 10
18
Deleting join association of has_many :through
I''m trying to use has_many :through, since my join model deserves being
more than just an intersection table.
But when I try to break the association, the break only seems
"temporary":
Let''s say my two tables are Users and Colors, and the join model is
Favorites.
user = Users.find(1)
user.colors.length
>> 2
c = user.colors.first
>> #<Color:....>
2008 Feb 28
2
change drop down list to radio buttons
In my RoR app I would like to change a drop down list, which dispays a
list of colors selected from the database. Instead I would like to
create a radio button for each color. The user is allowed to check one
color and this will be saved back into the database as the color for
this user.
I don''t know how to do this. Currently it looks like this:
<%= select(:user, :color_id,
2006 Apr 30
3
require "ajax_scaffold" in model error
Hi there,
I''ve got installed ajax_scaffold_generator (3.1.2, 2.2.1)
Anyway I''m following the example here <http://height1percent.com/
articles/2006/04/18/ajaxscaffold-3-1-0-released> which suggests the
following in a model file:
--------------------------------------------------------
require ''ajax_scaffold''
class Pet < ActiveRecord::Base
2010 Oct 06
2
reflect_on_association method
Hi all, I am having trouble trying to use reflect_on_association
method with given the simplified model:
class Order < ActiveRecord::Base
belongs_to :contractor, :class_name => "BusinessUnit"
end
I expected the reflect_on_association method to return
associated_foreign_key "contractor_id" but it returns
"business_unit_id":
ruby-1.9.2-p0 >
2006 Apr 13
5
Changing class data in environmrnt.rb
Greetings,
I have a class that should allow you define some default values. It
seems to make the most sense to do this environment.rb since its the
default app configuration. It currently looks like this:
Settings::DEFAULT_VALUES.merge!({
:setting_one => ''foo'',
:settings_two => ''bar''
})
The problem is in development mode, the values are only
2006 Apr 18
1
Pagination links with separator
Hi,
I have @result_pages and @results obtained from paginate in an action. I
want to show the pages as
1 | 2 | 3 | 4 >
The fifth page will show:
< 5 | 6 | 7 | 8 >
and so on.
How exactly do I render the paginator to give this effect? I guess I
will have to use pagination_links_each. But being new to Rails, I need
help.
Thanks,
Yash
--
Posted via http://www.ruby-forum.com/.
2006 Apr 13
7
Complex SQL in paginate command?
Hi all,
Is there a way to create pagination with a complex SQL, more complex
than the :conditions option will support?
I have two databases, houses and images. Houses has_many images, and
each Image belongs_to house.
I''m creating a search engine for the house records and I''d like to be
able to filter out all the houses without any associated images.
So far I''m
2006 Feb 19
2
progressive updates
I have a list view and have it sorting the data presented in the list
view by clicking on the top of the column - that works fine.
Now, I want to add a pop up-list which controls 3 different levels of
record select to be presented in this list...
- ALL
- placement.discharge_date IS NULL
- placement.discharge_date IS NOT NULL
I can have 3 different ''methods'' and
2006 Nov 26
5
associations help?
I have Users who can "own" Projects. There is only one owner. Users in
general can be authorized to view certain projects. Here is my initial stab
at this:
class User < ActiveRecord::Base
has_many :projects # ownership
has_many :project_viewers, :dependent => :destroy
has_many :projects, :through => :project_viewers, :uniq => true
...
end
class
2006 Oct 13
1
Edge rails, single table inheritance and keeping multiple classes in a single file
So is the official stance as per edge rails that multiple class
definitions must go into separate files? I was trying to use STI with
acts_as_attachment, to have all my attachment classes go into a single
file, for example:
attachment.rb
class Attachment < ActiveRecord::Base
end
class UserPicture < Attachment
belongs_to :user, :foreign_key => ''owner_id''
2006 Mar 22
3
Parent-Child Tables Help
can someone help me with this
i have a table
cars
(
id int
model_id int
make_id int
color_id int
description text
constraint fk_cars_carmake foreign key(make_id) references
carmakes(id),
constraint fk_cars_carmodel foreign key(model_id) references
carmodels(id),
constraint fk_cars_color foreign key(color_id) references colors(id)
)
carmakes
(
id int
carmake varchar
)
carmodels
(
id