similar to: instance variable problem

Displaying 20 results from an estimated 11000 matches similar to: "instance variable problem"

2006 Jun 13
7
help with ''error_messages_for''
Greetings, I''m in the throws of deploying an app on site5, and I''m getting strange errors. I think I might need to understand how error_messages_for works. I get a pretty standard looking error: " You have a nil object when you didn''t expect it! You might have expected an instance of ActiveRecord::Base. The error occured while evaluating nil.errors Extracted
2006 Jun 18
6
integer array columns
Postgres database. I have a categories table, with two columns id, and name. I have a recipes table, with a category_ids column. I want each recipe to belong to one or more category. in recipe_controller.rb I have this: def create @recipe = Recipe.new( @params[''recipe''] ) @recipe.category_ids = @params[''recipe''][''category_ids''].map{
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
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
2010 Dec 25
6
undefined local variable or method?
I have: <%= form_for(@supplier) do |f| %> ....... ...... <%= render ''sector_categories'', :locals => {:f => f} %> in _sector_categories partial I have: <div class="field"> <div id="category_update"> <% for category in @categories %> <%= f.check_box :category_ids[], category.id,
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
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
2006 Feb 14
7
9cays - A Rails app for Group Email
Even though it''s a little OT, I thought I''d announce the free public beta of a new Rails app that I''ve been working on for a while: http://9cays.com Think of it as mini-mailing list software. For a lot of smallish conversations, normal mailing list are too heavyweight (requiring setup, moderation, admin, etc.), but group email is a pain because messages
2006 Jul 09
8
Can the has_many create() method return an ID?
Hi all, I have a has_many relationship, Cookbook :has_many Recipes If I want to create a new recipe in my cookbook I do: cookbook.recipes.create(data) It would be nice if I could then easily get the id of the new recipe, but the create() method doesn''t seem to return anything. Any ideas how? Thanks in advance! Cameron -- Posted via http://www.ruby-forum.com/.
2006 May 21
3
Using ParseDate in for loop
Hi, I''m trying to use ParseDate within a for loop but I get this error: can''t dup NilClass Any suggestions for making this work? Thanks, -Jason
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
2006 Apr 05
3
CRUD pattern for has_many relationships (forms containing collections)?
Hello folks! Beare with me for a second, while I explain my problem. Assuming we have the trivial model of class Author has_many :books end class Book end How do people go about creating the authors/edit and authors/new views if you want to be able to add and remove arbitrary amount of Books at Author creation and edit time? What I mean by this is that I go to
2006 Jun 10
3
Weird Problem With Active Record
Is it me or is my model getting the created_at from the wrong model! I have a HABTM relationship between Problems and Tags. In one of my controller I do the following: def view @tag = Tag.find_by_name @params[:id] end In my view I do this: <% @tag.problems.each do |problem| %> ... <%= problem.created_at %> ... <% end %> Now, how come the created_at
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 Apr 14
1
Grouping a list of links by category
Hi, I want to display a list of links grouped by category like this: Group 1 Link 1 Link 2 Group 2 Link 1 Link 2 I have this in my controller: def index @links = Link.find(:all, :order => "category_id") end And this in the view: <ul> <% for link in @links %> <li> <a href="<%= link.url %>"><%= link.link
2006 Mar 04
6
Determine if a value is an instance of String , or Array , or...
each loop inside a mixed hash I need to determine if the value is an instance of String How ? hash.each do |k,v| if v ( instance of ) String hash[ k ] = v.capitalize enf end
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
7
going crazy!!!!!! ActiveRecord::StatementInvalid in Project
any suggestions on why I am gaining this error. ActiveRecord::StatementInvalid in ProjectsController#create Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' , , , , )'' at line 1: INSERT INTO projects (`name`, `date_created`, `quote_id`, `client_id`, `description`, `user_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