Displaying 20 results from an estimated 10000 matches similar to: "integer array columns"
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:
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
2006 May 09
6
Still Stumbled on First things in trying RubyOnRails
Still Stumbled on First things in trying RubyOnRails
http://www.digitalmediaminute.com/article/1816/top-ruby-on-rails-tutorials
http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html
http://instantrails.rubyforge.org/tutorial/index.html
http://rails.homelinux.org/
I had tried the first of the top 12 tutorials and got stuck after adding
a new field ?category_id?in the table recipes,
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 Jun 29
2
HABTM with multiple select list
Hello,
I am very new to ruby and need to create my first HABTM with multiple
select list.
I am having problems saving data in the middle(linking)
table.
1. titles can have multiple categories
2. categories can have multiple titles
Categories, titles and categories_titles tables are created.
----- title_controller.rb--
def new
@title = Title.new
@categories =
2006 Jun 07
1
How do YOU read/update HABTM?
In my mind, it should work like this:
<%= select ''item'',
''category_ids'',
Category.find(:all).collect {|c| [c.name, c.id] },
{},
{:multiple=>true, :size=>20} %>
Then Rails should automatically populate and update HABTM on that. As it
is now, the above won''t work (I created a getter in item''s model that
returns an array of
2005 Sep 25
7
(newbie) Missing Template Error using Rolling With Rails Tutorials
Hi all,
New to the list, Ruby, & RoR. I''ve been going through the Rolling
With Rails tutorial, but am getting the following error when the
instructions tell you to add the @recipes = Recipe.find_all line to
the RecipeController:
Template is missing
Missing template ./script/../config/..//app/views//recipe/index.rhtml
The index.rhtml file is right where it''s supposed to
2006 Apr 11
4
cookbook2
I am a new user to RoR/ I have been working on RoR cookbook2 tutorial
which could be found at
http://instantrails.rubyforge.org/tutorial/index.html. As I have been
going through different stages through trial and error, but now a stage
has come that i m stuck and not able to proceed any further. when it
comes to create a list.rhtml in recipe folder under views, and editing
the code which is
2005 Mar 06
2
Recipe Browser 0.4.1
I am please to announce the release of Recipe Browser 0.4.1. This
project (and files) can be located at
http://rubyforge.org/projects/recipe/.
This release brings Recipe Browser up to Rails 0.10, with a handful of
bug fixes. Special thanks to E Gard (x2egard) the newest member to
the project who also happened to do all the work for this release ;).
We would love to hear any questions,
2006 Jun 20
0
options_from_collection_for_select question
I am doing the recipe/category example, but with a
has_many_and_belongs_to relationship. To select categories for a
recipe, I have a select control. When editing, I want the proper
categories selected. In order to get it to work, I put this in my
_form.rhtml:
<select id="recipe_categories" name="recipe[category_ids][]" size="4"
multiple>
<%=
2006 Feb 14
1
Another HABTM Question
Hi there,
I have a question on what would be the best way to save a HABTM model.
A posting habtm categories, and a category habtm postings.
class Category < ActiveRecord::Base
has_and_belongs_to_many :postings
end
class Posting < ActiveRecord::Base
has_and_belongs_to_many :categories
end
In my blog_controller, where the actual posting is saved, is where I
think I''m
2005 Mar 09
9
Unit testing + instance variables
After *much* digging and playing around, I finally figured out how to
unit test instance variables that are created by actions. It was
more difficult than I expected. It seems like there should have been
a more straight forward way to do this. Can someone enlighten me? A
simplified and somewhat contrived example of what I am current doing:
Thanks.
Matt
>>
# My Controller of interest
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 Jul 05
1
newbie question: Mapping Collections
Hi,
Day 3 with rails here. Forgive me. If this has been covered many times
before, pls just point me at the article.
I worked through the Rolling with Rails tutorial
(http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html) built up my
cookbook. Things work great.
I now want to add Ingredients to my app. So, a Recipe will have 1 or
more Ingredients and any single ingredient can be
2006 May 31
3
instance variable problem
I''m having some trouble with an instance variable being read as nil in
my app. I have an image uploading, that can be added to categories.
The page loads up initially fine, and if I upload an image without
errors everything works fine. I''m working on the validation, but with
the code I have if their are validation errors it renders ''new'' again,
but reads
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: <%=
2007 Aug 01
2
map.resources with habtm
Hi
I''m trying to use restful resources with recipes and ingredients
I''ve set up the models using scaffold_resource.
A recipe can have many ingredients
and an ingredient can be in many recipes.
I''ve set the relationships up using a through.
I now want to display a recipe with a list of ingredients but I''m unsure
how to proceed.
Should I use nested resources and
2006 Jan 19
5
limits of has_and_belongs_to_many
I''m experimenting with Rails on the Recipes example first before I dive
into applying it to my intended application. I''m exploring which will be
more work: to rename all the primary id''s in the legacy database, or to
work around the fact that the primary id''s are not called ''id'' within
RoR instead.
I''ve been successful in using a
2006 Aug 19
3
Special ruby language for describing sql conditions
I was brainstorming today about a smooth way to define conditions in an
sql query, when the numbers of attributes increase, so does the uglyness.
So instead of passing a hash, I thought you could specify the conditions
directly in code.
I hacked together some example code which actually turned out to work.
The result is concise and pretty beutiful.
def search(params)
Ad.find(:all) do
2005 Dec 19
2
Difficulty using correct moldel for the data in DB
Hi everyone,
I''ve tried posting the same question to the list last Friday but
somehow did not see it being posted..
I''ve just started with Rails and Ruby. I just started to play one of
those RPG and to get my feet wet I''m writing an app to keep track of
item fusions. So the scoop is that item can be fused with another
items to create a higher level item. The higher