Displaying 20 results from an estimated 10000 matches similar to: "Trouble getting select to work"
2006 Jan 13
3
related drop down list / ajax
Hi all,
I''m trying to create a related dropdown box:
In my view:
<select name="category" id="category">
<option value="">Select category</option>
<% @categories.each do |category| %>
<option value="<%= category.id %>">
<%= category.title %>
</option>
<% end %>
2006 Apr 22
6
nOOb question: How to use find_all with form input data
Hello,
I''m having a problem utilizing the find_all method with a value from a
form. I keep getting the following error:
Mysql::Error: #42S22Unknown column ''category_id11'' in ''where clause'':
SELECT * FROM items WHERE (category_id11)
The controller seems to be getting the correct data, but my key and
value seem to be mashed together(it''s
2006 Jan 13
4
missing foreign key fields in scaffold views
Is there any reason that foreign key fields do not show in any of the
scaffold views ?
project table:
id serial primary key,
category_id integer,
user_id integer,
name varchar,
morestuff varchar
foreign key (category_id) references categories(id),
foreign key (user_id) references users(id)
scaffold generated views only show name, morestuff fields
2006 Jul 15
7
:maxsize => 30 in form not working
Well, I''ve researched the books and the web to no avail (I tried the search here too but kept getting page not found.I''m doing what the examples say to do but I cannot get this work. The form allows entry of characters beyond the maxsize which causes the app to abend giving me the browser page showing a trace with the following info preceding the trace:
Mysql::Error:
2006 Jun 29
2
? concerning ActiveRecord, Action and template
Much appreciate any help here. I''m just getting started learning RoR and
setting up my first form is throwing me - I''m not getting the concepts
formalized in my mind.
Situation:
- Controller is: Donation
- Action is: donation_entry
- Template is: donation_entry.rhtml
This form will be displayed when selected from sidebar menu (which will
always be present for all
2006 Jul 07
8
Possible name clash?
Scenario:
Table in database has two fields, id and category (table name is:
categories)
Controller is named category_controller.rb
Model is named category.rb
Helper is named category_helper.rb
Form is named list.rhtml in view\category directory
The code in play on the form is (from generating scaffold):
<% for category in @categories %>
<tr>
<td><%=
2006 Jan 15
4
form inputs resetting on sumbit
I searched for forum for something about this but couldn''t find
anything.
For example I have this in my view: (you enter start/end dates from
dropdowns, pick a category and a report is generated.)
<%= start_form_tag :action => ''display_report'' %>
From: <%= date_select ''report'', ''date1'' %> <br />
To: <%=
2006 May 11
6
ActiveRecord associations
Can someone clarify this for me? Suppose I have two tables like:
class Company < ActiveRecord::Base
belongs_to :category
end
class Category < ActiveRecord::Base
has_many :companies
end
I understand that the belongs_to causes related companies to be read
from the db when I ask for a category. I suspect SQL something like
select * from categories, companies
where category.id
2006 Jan 10
5
Select Tag and Associations
Hi there,
I''ve been working on this for awhile and have finally decided to ask
for a little guidance.I have a slight problem trying to save a
selection.
I have two models:
A "Posting" has_many "Categories", and a "Category" belongs_to one
"Posting". With that said, in the posting model I have "has_many
:categories" and within the
2006 Mar 30
5
Heeelp - no idea what''s going wrong.
I''m working on a simple CMS. The main data type are "listings" a listing
habtm (has_and_belongs_to_many) categories and subcategories.
Subcategories belong_to categories. Subcategories are basically the same
as categories, but they are treated differently in a few situations.
The problem is, I can''t seem to write the view/controller/model code
that allows me to
2006 Apr 16
11
Best way to sort categories w/ pager
Ahoy,
I made this pager,
" def list
@item_pages = Paginator.new self, Item.count, 10, @params[''page'']
@items = Item.find :all, :conditions => "category_id =
#{params[:condition]}",
:limit => @item_pages.items_per_page,
:offset => @item_pages.current.offset
@categories = Category.find_all
2006 Jan 03
4
validates_presence_of *_id attributes
Hi all,
I am a newbie to Rails. Please enlighten me on how to do this
appropriately, the Rails and the Ruby way:
Suppose I have a Recipe model. Let''s simplify things and pretend that
it has only 2 attributes, a :name and the other is a ''category_id''. In
the recipes table, category_id is a foreign key to field id of table
categories.
We also assume that I have generate
2006 Apr 15
8
Inheritance in Rails - I need some help
I''ve got a model, "category" and another model "subcategory." Each
subcategory belongs_to a category, and a category has_many
subcategories.
What I need to do is set it up so that I can search Category and
Subcategory with one .find call. So:
Category.find(:all, <etc)
will find categories and subcategories.
Now, I believe this can be done by making
2006 Jan 06
3
Cookbook recipes eg - ordering categories in the recipe pull-down box
People,
I can order categories when looking at the categories list page but how
do I change the recipe page to list the categories in alpha order in the
recipe pull-down box?:
> <p><b>Category:</b><br>
> <select name="recipe[category_id]">
> <% @categories.each do |category| %>
> <option value="<%= category.id
2010 Nov 24
3
Wine nominated as best open source
Wine has reached the final round in the category: "Best Open Source of 2010" which gives a donation of EUR 300 to the winner. I recommend to vote for Wine (http://www.portalprogramas.com/software-libre/premios/proyecto/75)
2006 Jun 14
13
Undefined method
I really hope this is not a bad question (as in he''s abusing the
list). However I could use a little direction (even though I''m
reading books, tutorials)
Right now I''m getting a
undefined method `category'' for 4:Fixnum
The specific lines from the rhtml file are:
<td><%= link_to position.category_id.category, :action => "show", :id
=>
2010 Mar 27
2
Shorter Rails 3 routes
Hi,
I have a small blog application, and I would like to shorten its routes.
Here they are:
Blog::Application.routes.draw do
resources :categories do
resources :articles do
resources :comments
end
end
A rake routes command produce the following lines:
GET
/categories/:category_id/articles/:article_id/comments(.:format)
2006 Jan 07
2
help
I am at a lost with error below:
Extracted source (around line #15):
12: <p><b>Category:</b><br>
13:
14: <select name="product[category_id]">
15: <% @categories.each do |category| %>
16: <option value="<%= category.id %>"
17: <%= ''selected'' if category.id == @product.category_id
2006 Mar 29
11
why belongs_to does not like validation?
This works :
class Recipe < ActiveRecord::Base
belongs_to :category
end
But (when I add validation) this does not work :
class Recipe < ActiveRecord::Base
belongs_to :category
validates_length_of :category, :within => 6..20
validates_uniqueness_of :category, :message => "already exists"
end
thank you
--
View this message in context:
2009 Jun 22
5
has_many through , or habtm , using form
i think there ara two ways of relate products and categories ,
basically i want to fix one product(e.g hp dv7....) to some categories
(notebook,17"notebooks...)
i made a table named categorization(incuding category_id,product_id
fields) then in models i write these codes below
class Product < ActiveRecord::Base
has_many :categories, :through => :categorizations