Re: [Rails] Re: Re: Logging in Rails

2010-03-16 Thread Anthony Gardner
If, in your application you are expecting value_a but it's either nil or you have another value, that could be logger.error (if it's critical to the continuation of the application) or if you can work around it but want to be notified about it to sort it out in the future it could be logger.warn,

[Rails] DB in Non-Standard Place

2010-03-16 Thread Anthony Gardner
I'll be doing a deployment soon and looking ahead to the future, I was wondering what people do with regarding putting a SQLite db in a non standard place. The simplest solution to get it out of the app is to move it to another directory and have rails find it at server startup. Where can I put ru

Re: [Rails] Re: validates_presence_of :parent_id stopping save

2010-03-15 Thread Anthony Gardner
I don't have your original mail and am not sure of the model but question_id is a foreign key.No? You are checking for the existence of it before it has been created, that is why it's failing, no? validate methods validate the data before its saved. Unless I'm missing something from your original

Re: [Rails] validates_presence_of :parent_id stopping save

2010-03-14 Thread Anthony Gardner
Hi, I'm not sure 100% what you're trying to do but the presence of question_id will not be there until the record has been saved. No? And I'm not sure why you're doing this @grading = @question.gradings.build(more_attributes) Shouldn't you have done a build before presenting your form if yo

Re: [Rails] How can I conditional the validation on a model validation?

2010-03-14 Thread Anthony Gardner
If you're asking "how do I avoid the validation check on name and id when updating", then you should look at :on => params for validation. validates_presence_of :id, :name, :on => :create I think everything is clearly explained in the docs. http://api.rubyonrails.org/classes/ActiveRecord/Validat

Re: [Rails] Where to find plugins?

2010-03-10 Thread Anthony Gardner
Github might be your friend On 10 March 2010 14:27, Aldric Giacomoni wrote: > Is there another place than agilewebdevelopment.com/plugins to find a > list of Rails plugins? > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google G

Re: [Rails] Re: Modelling Question

2010-03-07 Thread Anthony Gardner
Sorry for the delay in getting back on this but I've just got back from a weekend away. Okay, so Max, you and I agree on the modelling for this concept so that starts to narrow down where my problem is. To begin with, I thought my problem was because I had a join model acting as the parent to ano

[Rails] Modelling Question

2010-03-05 Thread Anthony Gardner
Let's say I have the following real life objects Books, Authors, Roles. A Book can have one or many Authors and an Author can have one or many Books. An Author can also have one or many roles associated with a book (maybe they're the author, or co-author, or commentator to whatever) How would you

[Rails] Question about Nested Join Tables

2010-03-03 Thread Anthony Gardner
I have five tables that I am trying to get to work nicely together but may need some help. I have three main tables: accounts, members and roles. With two join tables account_members and account_member_roles. The accounts and members table are joined by account_members (fk account_id and member_i

[Rails] Crummy Breadcrumbs

2010-02-26 Thread Anthony Gardner
I'm using the latest crummy breadcrumb plugin and I like it but I can't figure out how to add values (:id for example) to the URL. Plain URLs are obviously no problem. I've looked at the crummy.rb code and read the docs but still couldn;t figure it out. Any pointers would be great. Thanks. -ant

[Rails] Installing Plugins

2010-02-16 Thread Anthony Gardner
Coming from Perl and familiar with CPAN, I'd like some info about installing plugins. Basically, do I trust where the libraries are installed? For example, I have installed the Liquid plugin (./script/plugin install http://liquid-markup.googlecode.com/svn/trunk ) and the installation directory i

[Rails] Decent Implementation using ActionMailer

2010-01-22 Thread Anthony Gardner
I need to implement some email functionality to a web application and I was wondering if anyone has implemented a decent mail system and could possibly give me some tips. My initial designs are leaving me a bit cold. In a nutshell, I'm thinking of giving the user the ability to create their own te

[Rails] Re: Best Practice For Displaying Data

2009-10-30 Thread Anthony Gardner
rom is needed. Thanks for your help -ants 2009/10/30 Rob Biedenharn > On Oct 29, 2009, at 6:07 PM, Anthony Gardner wrote: > > Simplified, I have the following relationships > > term has many swimming_classes and a swimming_class belongs to a term > swimming_pool has many swimmi

[Rails] Best Practice For Displaying Data

2009-10-29 Thread Anthony Gardner
Simplified, I have the following relationships term has many swimming_classes and a swimming_class belongs to a term swimming_pool has many swimming_classes and a swimming_class belongs to a swimming_pool terms (date_from)-- swimming_classes (start_date) -- swimming_pools (name) I

[Rails] Multi Select with fields_for

2009-10-26 Thread Anthony Gardner
I'm trying to get a multi select box working with fields_for but am having a few problems. My view has <% form_for(@teacher) do |f| %> <%= f.label :surname %> <%= f.text_field :surname %> <% f.fields_for :qualifications do |qual_form| %> Qualifications: <%= qual_form.select( :id,

[Rails] Multi Select and Virtual Attributes

2009-10-21 Thread Anthony Gardner
Using Rails 2, I have multiple objects in a form and am using fields_for. My problem is creating a multi select and sending that off to the controller as a hash. In my erb, I have <% teacher.fields_for :qualifications do |qual_form| %> <%= qual_form.select [], @qualifications, { :multiple

[Rails] Re: nil object problem

2009-08-31 Thread Anthony Gardner
2009/8/31 Frederick Cheung > > > > On Aug 31, 8:16 pm, Anthony Gardner wrote: > > Frederick, > > > > Thanks for getting back but you're missing the point, they're working on > > the same data. > > I realise. > > > > The .each b

[Rails] Re: nil object problem

2009-08-31 Thread Anthony Gardner
t; > > > On Aug 31, 7:57 pm, Anthony Gardner wrote: > > This is a repost as I had zero replies to my first email. This problem is > > driving me mad but it has to be a simple solution that I just can;t see. > > > > Can someone please tell me what the dif

[Rails] nil object problem

2009-08-31 Thread Anthony Gardner
This is a repost as I had zero replies to my first email. This problem is driving me mad but it has to be a simple solution that I just can;t see. Can someone please tell me what the difference is between the following bits of code <% @swimming_class.lessons.each do |lesson| %> <% lesson.

[Rails] Nil object nightmare

2009-08-28 Thread Anthony Gardner
I'm having a real problem with nil objects in a view I'm playing with. if I type ... <%= debug lesson.lesson_register.attendees %> I get the following displayed in the browser - !ruby/object:Attendee attributes: enrollee_id: "25" created_at: 2009-08-27 15:10:41 updated_at: 20

[Rails] Playing with routes Rails 2.3

2009-07-28 Thread Anthony Gardner
Okay, I'm just getting back into using Rails for a few private projects and am trying to stick to the RESTful way of doing things. If I have a teacher model and a lesson model, the basic scaffold setup to create these items is fine. But then I have the relationship that a teacher habtm lessons and

[Rails] Re: Problems with accepts_nested_attributes_for

2009-07-23 Thread Anthony Gardner
nd_to do |format| > format.html # new.html.erb > format.xml { render :xml => @parent } >end > end > > It should work exactly the same way with the has_many, :through > association. Hope this helps! > > - pat > > > On Jul 21, 3:10 pm, Anthony G

[Rails] Problems with accepts_nested_attributes_for

2009-07-21 Thread Anthony Gardner
Hopefully someone can help. I have the following models class Parent < ActiveRecord::Base ## schema id int, name string has_many :children accepts_nested_attributes_for :children end class Child < ActiveRecord::Base ## schema id int, name string, parent_id int belongs_to :parent end ..