|
I've upgraded to Rails 2.3.3 (from 2.1.x) and I'm trying to figure out the accepts_nested_attributes_for method. I can use the method to update existing nested objects, but I can't use it to create new nested objects. Given the contrived example:
class...
Started by peterjm on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
One solution is to set up a virtual attribute....
I expect this to be much improved in Rails 3, but in the meantime you'll have to do a workaround .
There is an existing LightHouse ticket which is worth checking out .
This is a common, circular dependency issue.
|
|
Note: Posting this as a separate question as per Brian's comment (from http://stackoverflow.com/questions/892624/how-to-handle-multiple-models-in-a-rails-form )
I'm trying to learn the best way to handle multiple models in a single rails form, when the...
Answer Snippets (Read the full thread at stackoverflow):
You might want to take a look at this to handle multiple instances:
http://railscasts.com/episodes/73-complex-forms-part-1
Also, I think I've answered your second question here:
http://stackoverflow.com/questions/889608/validating-multiple-models-in-a... .
|
|
Does anyone know how to make nested server controls accept nested html without "injecting" it out from serverside, ie.
<uc1:CustomServerControl runat="server"> <NestedControl></NestedControl> <NestedControl2></NestedControl2...
Started by BK on
, 4 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Try this:
[ToolboxData("..."), ParseChildren(false), PersistChildren(true)] public class CustomServerControl : WebControl, INamingContainer { }
The purpose of this basicly is to have a custom Generic tag library, whick in this case will speak to a underlying... .
|
Ask your Facebook Friends
|
I have a web service in C# and would like to have a nested inner class, that abstracts away the session collection, something like this:
public class Service : System.Web.Services.WebService { [WebMethod] public string Foo(string ticket) { SessionPool...
Started by mmattax on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
There is no implicit reference to an instance of the containing class - so you can't use any instance members of the containing class without... .
System.Web.HttpContext.Current
?
Nested classes in C# aren't like (non-static) inner classes in Java.
|
|
Is it possible to automatically assign a specified layout template to a particular controller and all of the resources nested within it, as specified in routes.rb? This layout should apply only the specified controller views and those nested within it...
Answer Snippets (Read the full thread at stackoverflow):
You'll have to make sure your @news instance variable is set and your form... .
For your news.html.erb problem, is that a typo? You should see your new.html.erb file that's in your views/articles folder (assuming default layout) and not a news.html.erb file .
|
|
I was wondering if there is a performance difference when using ifs in C#, and they are nested or not. Here's an example:
if(hello == true) { if(index == 34) { DoSomething(); } }
Is this faster or slower than this:
if(hello == true && index == 34) { DoSomething...
Started by Bevin on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
Unless performance is really a critical factor for your application, I would automatically choose the second version, for the sake of code readability... .
Probably the compiler is smart enough to generate the same, or very similar code, for both versions .
|
|
Hi folks,
I've the following code in a _form.html.haml partial, it's used for new and edit actions. (fyi I use the Ryan Bates' plugin nested_form )
.fields - f.fields_for :transportations do |builder| = builder.collection_select :person_id, @people, :...
Started by Denis on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Here's the documentation for the Rails way to do fields_for...it's ... .
What you are doing (specifically with the fields_for method) may be conflicting with RAils' built-in way to render fields_for .
Nested forms are officially supported with Rails.
|
|
Premise: Usually during preparation of a new Ruby on Rails App, I draw out models and relations regarding user navigations. Usually I hit a place where I need to ask myself, whether or not I should go beyond the usual "rule of thumb" of nesting no more...
Started by Anthony on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Edit: If you are going to nest more than 1 level I would check out the new shallow routes feature in Edge
users/:user_id.
I tend to follow Jamis Buck's advice and never nest more than one level deep.
|
|
I have a Bill model with nested Customer model. The Customer model has a phone number with a uniqueness validation on it. While creating the bill I want to fetch the existing record based on the phone number or create a new one if such doesn't exist. ...
Started by TMaYaD on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
You would use the find_or_create_by method which would look something like this in your... .
A little Googling should get you there the rest of the way, I think .
You can look at the find_or_create or find_or_create_by methods (which are dynamically created) .
|
|
I'd like to have something that looks and behaves as hyperlink inside larger rectangle (full page wide) which is also hyperlink. Below there is ASCII-art representation of what it should look like:
| | | Some text [_link_] | | |
The whole outer rectangle...
Started by Jakub Narębski on
, 6 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Something like this perhaps....
What I have done in the past is use Javascript to attach the proper functionality to the div (assuming that is the parent element) so that when it is clicked, window.location is ran opening the .href attribute of the child link .
|