You could create a constant in your ServiceDesk or OpenServiceDesk
model (not sure how you've set your models up)...

class ServiceDesk < ActiveRecord::Base

  DEFAULTS = {:service_desk_status_id => 1, :service_desk_category_id
=> 1, :service_desk_sub_category_id => 1}

end

Then in your controller you could use
yourobject.service_desk_status_id = DEFAULTS[:service_desk_status_id]

Perhaps there's a good argument against using a constant like this, I
don't know, but to me it looks like a pretty simple way to do it.

Or, as Fred suggested, create a migration to make the DB handle the
default values, like so:

change_column :tablename, :service_desk_status_id, :integer, :default
=> 1

On Nov 3, 4:21 am, Daniel Bush <[EMAIL PROTECTED]> wrote:
> On Nov 3, 6:41 pm, Sijo Kg <[EMAIL PROTECTED]> wrote:
>
> > Hi
> >   Thanks for the reply.May I ask one more question? As  Daniel Bush said
> > this isn't a test fixture but just a file that is being used to set
> > default values..So my question normally in which directory I can store
> > this yml file whether inside models or view or anywhere?
>
> I can't see the reason for using yaml like this - but I guess you have
> your reasons.
>
> Since you're set on having your controller load up a yaml file every
> time it's accessed then I'd probably stick it in db/ somewhere.    As
> Fred says, you could put it anywhere.
>
> You could lazy load it to save hitting the file system every time:
>   class YourModel < ActiveRecord::Base
>     def YourModel.default_values
>       @@default_values ||= YAML.load_file(RAILS_ROOT+'/db/
> get_value.yml')
>     end
>   end
>
> --
> Daniel Bush
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to