similar to: About a simple insert

Displaying 20 results from an estimated 50000 matches similar to: "About a simple insert"

2007 Jun 19
3
Nil object for nested resource
Hi all, I have 2 models with a standard 1 to many relationship. I''m also using REST on the two models and have added the appropriate code to the routes.rb file. scorecard.rb: class Scorecard < ActiveRecord::Base has_many :attributes end attribute.rb: class Attribute < ActiveRecord::Base belongs_to :scorecard end routes.rb: map.resources :scorecards do |scorecard|
2007 Dec 22
3
collection_select validation problem
I''m trying to assign a parent foreign key value using collection_select from my child "new" form. The problem I''m having is if I do not make a selection, I get the following error instead of the Rails validates_presence_of error: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occurred while evaluating
2005 Dec 29
3
Post problem with select lists
hey, i have this problem how come i always get -1 for the select list?? rhtml First, select a client. <select id="client_id" name="client[id]" onChange="submit();" > <%= options_for_select(@client_options, @client_id.to_i) %> </select><%= @client_id %> controller if @request.post? if @request.xml_http_request? #called by ajax,
2006 Dec 29
2
update_attributes fails: ReadOnlyRecord
I''m trying to update a record, but it just stops with "ActiveRecord::ReadOnlyRecord". I don''t understand why, because I never wanted my model to be read only. Relevant code: Controller: def edit @project = find_project if request.post? @project.update_attributes(params[:project]) if @project.save flash[:message] = _(''Project was
2007 Nov 19
2
Help with controller and view
I have the following models class Recipe < ActiveRecord::Base has_many :ingredient_recipes has_many :ingredients, :through => :ingredient_recipes end class IngredientRecipe < ActiveRecord::Base belongs_to :ingredient belongs_to :recipe end class Ingredient < ActiveRecord::Base has_many :ingredient_recipes has_many :recipes, :through => :ingredient_recipes
2007 Sep 17
8
DISTINCT?
This should be easy, but I''m stumped... class X < ActiveRecord::Base belongs_to :y end class Y < ActiveRecord::Base has_many :x end The y table has a column names. The x table has a column value. I want the list of values in x for the name "Location" in y. Yes, there are many repetitions. I can probably hack together an SQL statement to do this without too much
2007 Apr 10
7
Newbie :: Help !!! (database record compare)
Hi all, I''ve a two simple table, resource ======= resource.id resource.name resource.contact and project ====== project.id project.name project.resource_id (id from resource table) I want to display list of project that only belong to particular resource. my proj.rhtml is like ===================== . .. ... <h1>Projects</h1> <table border="1">
2006 Feb 06
3
linked table confusion
placement.rb has_one :client has_one :case_manager client.rb belongs_to :case_manager has_many :placements case_manager.rb has_many :clients has_many :placements I am trying to create a view file for placements. I can pull columns from clients table in this view by using... <%= @placement.client.wholename %> but if I use <% @placement.case_manager.wholename %>
2006 May 17
2
Association data clobbering (foreign keys too?)
Can someone please confirm or correct the following statements? If I have the following tables create table as (id int, [...], b_id int); create table bs (id int, [...], a_id int); create table as_bs (a_id int, b_id int); and the associations woould be defined like this class A << ... habtm :bs belongs_to :b end so my Model A has a habtm collection of Bs *plus* a direct
2006 Nov 27
3
ActiveRecord: Reference same table twice
Hi, I have 2 tables, "users", and "user_comments". I am trying to allow users to leave comments on each other''s profiles (eg, think youtube like this: http://www.youtube.com/profile_comment_all?user=google). Here is a simplified view of my database schema: mysql> describe users; +-----------------+--------------+------+-----+---------+----------------+ | Field
2006 Jun 13
13
Pass infomation between different views and controllers
Hi, I am a rails and ruby nuby :-) How do you pass data between different controllers and views? I have a page ( a quote) that I am editing url ....quote/edit/6 6 id the current id. I then go to a catalog (url....catalog) to add an item to my quote (I do this via a line_item file that the quote reads) I now want to go back to the quote. I have tried this <%= link_to ''Back to
2007 Nov 29
4
collection.build or collection.create gives "ArgumentError: wrong number of arguments (1 for 0)"
I have a Project that has_many Tasks. Tasks belongs to a Project. When I try the following: project = Project.new project.tasks.build I get: >> s = Project.new => #<Project:0x25f9e28 @attributes={"name"=>"", "end_at"=>nil, "updated_at"=>nil, "published_at"=>nil, "user_id"=>nil,
2006 Feb 24
7
One To Many To Many
Hey all, I''m trying to find a simple way to reference all of the objects that belong to their parent''s parent. In other words: Clients --> Orders --> LineItems How do I get all of a client''s lineitems in one array (i.e., client.all_lineitems)? Thanks! -Neal -- Posted via http://www.ruby-forum.com/.
2006 Apr 16
5
render :collection and default value
Hi all, I am having a lot of trouble to get the default value of text fields when they are generated by a partial from a collection. I have been on this for a whole week and I didnt find a single exemple on the internet of someone using a partial that generate text field with a default value. I cant believe that I am the only one having this problem. Anyone has an exemple they can show me?
2007 Oct 06
4
Passing ERB block to helper
I''m trying to pass an ERB block to a helper, and I''m not able to achieve the results I want. The helper should take the block and incorporate it into some other text & html, before finally outputing it back to the ERB template. Here''s what I want: --helper-- def helper (a, b) yld = yield out = --some function of a, b, and yld-- out end --ERB-- <%
2007 Oct 24
4
before_filter at the method level
I have used before_filter in the passed at the class level but can it be used in the method level. For example, I want to refuse a non-admin type from being able to delete anything in the entire application. Is there an easy way to do this? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the
2007 Oct 16
8
Using multiple foreign keys in views
I have a model, Game, that has_many :teams. There''s a home team and an away team. I created two foreign keys, so each game can have two teams associated with it. Here''s the Team model: class Team < ActiveRecord::Base belongs_to :game, :class_name => ''Game'', :foreign_key => ''hometeam_id'' belongs_to :game, :class_name =>
2006 Apr 27
4
select item based on previous select list selection?
So I have a select list with a list of items. When a user selects an item, another select list should have its default selected item set to a specific item (the default associated with the first select list). This is in a form to create a new task. The first select list is a list of parent tasks. When one selects the parent task, the clients select list must default to the same client as its
2008 May 04
5
simple Routing Error
Routing Error No route matches "/user/register" with {:method=>:get} The URL is http://localhost:3000/user/register Here is app/views/user/register.rhtml <h2>Register</h2> <% form_for :user do |form| %> <fieldset> <legend>Enter Your Details</legend> <div class="form_row"> <label
2007 Oct 18
4
Polymorphic Association?
Hi there- I''m a newbie to this board, RoR, and web development in general. So please forgive me if this is in the wrong place or if the solution is really simple... I''m trying to conceptualize the relationships between a series of models for a page creation function. What I''d like is to have a Content Page which consists of a series of Content Blocks. The Content