Displaying 20 results from an estimated 500 matches similar to: "active admin saving selection from collection_select and passing to controller"
2006 Apr 07
0
Updating a relationship in a has_many and belongs_to
As the subjects suggests I''m trying to reiterate through certain pages,
assigning them to certain menus. My code is as follows
When I run the Below the position updates fine, but the menu_id in Page
doesn''t seem to change it all.
params["group_#{params[:id]}"].each_with_index do |id, position|
Page.update(id, :position => position + 1, :menu => menu)
end
2006 Dec 06
2
validates_uniqueness_of where scope euqals created_by "magic" field
I have the following ActiveRecord objects:
class Recipe < ActiveRecord::Base
has_many :ratings, :dependent => true
. . .
end
class Rating < ActiveRecord::Base
validates_uniqueness_of :created_by, :scope => :recipe_id
belongs_to :recipe, :counter_cache => true
. . .
end
The created_by field on Rating is implemented as a "magic" field
similar to this:
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
2013 Jan 27
0
Nested form for a has_one model that already exists
Here''s the gist of my problem: (using formtastic)
Models:
Person (has_one :color)
Color
So I have this database full of already populated Color entries via a
whole separate controller + views for creating Colors. When creating a
person, I want to be able to select a Color object without creating it.
So I''m not looking for something such as:
= semantic_form_for @person do
2008 Jul 24
0
Getting Foreign Key to work!
Okay. So I have this simple site, which includes Recipes and then
Comments.
I want ppl to be able to comment on the recipes, and so I made comments
have a recipe_id as it''s foreign key etc. I''m not that much of a noob
to not know that stuff.
When I click on a recipe, and then make a new comment and click ''submit''
(for the comment) it submits it, but it still
2011 Feb 19
2
Active Record Query
A course has many lessons and a lesson has many topics.
A topic can have a recipe or vice versa, a recipe has many topics
(optional).
I need to come up with the most efficient way of querying the database
to find those topics belonging to a course (via lessons of course) which
have a recipe (in other words recipe_id is not null for this topic
record).
Simple but challenging :)
Thanks for your
2012 Sep 22
1
formtastic does not save at all
Rails 3.1.3
I am using Formtastic gem in order to deal with multi-select
dependencies.
<%= semantic_form_for(@give) do |f| %>
<%= f.inputs do %>
<%= f.input :departure,
:collection => Departure.find(:all, :order=>:city).collect{ |c|
[c.city,c.id]},
:required=>true %>
<div id="destinationCity">
<%= render :partial =>
2012 Aug 25
0
accepts_nested_attributes_for and fields_for not working!
I want to be able to create one menu object that has fields_for :brunch,
:lunch, and :dinner. The menu object has_many brunches, lunches, and
dinners, but each time I "edit", only one brunch, one lunch, and one dinner
object are added. I''m using carrierwave to upload brunch_menus,
lunch_menus, and dinner_menus (attributes of brunches, lunches, and dinners
respectively) as
2010 Aug 17
2
[Form] Method POST & PUT problem
Hello,
I have a form that should be a POST method, but Rails insist to put a
hidden field "_method" that has the value "put" does anyone knows why?
Thanks,
David Sousa
Controller: -------------------------------
def new
@user = @current_user
end
-------------------------------------------
View: -------------------------------------
<% semantic_form_for @user,
2012 Nov 12
1
undefined method `original_filename' for nil:NilClass
Hi, although I saw this problem in other blogs, I couldn''t make it works.
My view:
*<%= semantic_form_for :routes_status_race, :url =>
status_race_admin_routes_path do |f| %>*
* <% contact_array = Contact.all.map {|contact| [contact.name,
contact.id]}%>*
* <% route_importer_array = RouteImporter.all.map {|importer|
[importer.name, importer.id]}%>*
* <%=
2010 Jan 20
0
need help with nested forms and habtm
Hi,
I''m currently stuck with a problem I just can''t find a clever solution
for. I checked every tutorial, issuetracker, API reference I could
find but found nothing to "enlighten" me --> I desperately need your
help :-).
My Question is: is it possible to use nested forms for habtm
associations?
--> Here some more info about what I wanted to do and what failed
2006 Mar 07
1
Error when trying Rolling with Ruby On Rails
Hi everyone!
Please excuse my ignorance!
I was working through the Rolling with Ruby tutorial to get a feel of
things. Everything seems to work until I tried editing as in the last
example in part 2 when I got the following error -
|Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
|||
Extracted source (around line *#8*):
|5: <body>
6:
2006 May 07
6
RuntimeError in Recipe#edit
I have tried to learn ruby on rails from scratch by going into a
tutorial at the following website.
http://instantrails.rubyforge.org/tutorial/index.html
I followed the suggestions and encountered 3 problems so far.
1. Couldn''t start the Apache server. Error message "Port 80 was used by
some other process." I over-came the problem by going
into configuration and change the
2006 May 20
3
In a find, can''t you use both :include and :limit ?
I''m trying to do a find that includes a join. It has to be a find
because I''m using the results for a Pagination, so I need to limit my
query to the number of results I want to display per page.
Here''s the type of thing I want to do:
Employee table <-> Skills_Employees table <-> Skills table
Let''s say I want to find all the employees who have
2006 Apr 27
3
collection_select to display 2 fields
I''m trying to get a collection_select generated Drop-down box to display
two fields from a table (first name & last name); however, I am having
trouble concatenating the symbols. It appears as though any code I put
in the 5th argument for collection_select is processed prior to
executing the collection_select method. The code executes successfully
with 1 symbol in the 5th
2006 Jun 22
2
Setting an index on a collection_select
I am creating a data entry form that allows a user to fill in multiple rows
and save them all at once. In my controller, I create an array of "person"
objects and pass it to the page. On the page, I have a text field like so:
<%= text_field "person", "name", "index" => 1 %>
Note the "index" attribute, which sets the name and id
2006 Aug 17
3
Use collection_select
I use the following code in my view:
<%= collection_select(''datedata'', ''date'', @allDate, :id, :date) %>
It''s show me the date of all entries in the database (Dropdown menu).
Additional, I wrote a helper method "showDate" in the
application_helper.rb! How can I use this method in the
collection_select for every date entry?
thanks
2010 Aug 30
1
update form text_field on collection_select selection
I have form and a collection_select control. I would like to update
form fields (text box) when I select an item from the collection_select
box.
It''s like selecting template from the collection_select and the template
automatically loads to text boxes.
Any help?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
2006 Nov 28
2
collection_select and selected_value
Hi,
I am using collection_select to build a drop down list. I would like
to have the current value selected. How can I do that?
My current code is straight from the example in Pragmatic Programmers
book [2nd ed, p480] copying here for reference.
<%=
@users = User.find(:all, :order => "name" )
form.collection_select(:name, @users, :id, :name)
%>
I went through the api docs
2006 Aug 16
1
how to update a collection_select from another
I have two collection_select in my list.rhtml:
<%= collection_select (:region, :id, @regionall, :id,
:title,html_options={:onChange => "new
Ajax.Updater(''related_provinces'',''/categories/related_provinces/" +
"?id=''+this[this.selectedIndex].value,
{asynchronous:true, evalScripts:true});"}) %><br>
<%= render :partial =>