[Rails] Re: Re: Re: Use Polymorph or STI or.

2015-12-17 Thread Travis Eubanks
> Is the gl code a unique number that identifies the type? If so then > that should be stored in the db but the string should not, since it > can be determined from the string. Alternatively put the string in > the db and not the code. It is almost always a bad idea to store > redundant data in

[Rails] Re: Covert Hijiri Date to Gregorian Date

2015-12-17 Thread Matt Jones
On Wednesday, 16 December 2015 03:36:09 UTC-5, honey ruby wrote: > > Hi, I want to convert Hijiri Date to Gregorian Date I have tried gem > 'hijri2greg_date' but it is not showing correct Gregorian date. Is there > any other gem which converts correctly and best way. > > Thanks in advance > Yo

Re: [Rails] Re: Why doesn't collection=objects on has_many :through trigger destroy callbacks on the join model?

2015-12-17 Thread spike22
Haha! very good :) On Friday, December 18, 2015 at 10:39:49 AM UTC+13, Eric Krause wrote: > > I just did that this morning. > > On Thursday, December 17, 2015, spike22 > wrote: > >> Hi Eric, that's really interesting! I'll give it a whirl and report back >> :) I might do a documentation pull re

Re: [Rails] Re: Why doesn't collection=objects on has_many :through trigger destroy callbacks on the join model?

2015-12-17 Thread Eric Krause
I just did that this morning. On Thursday, December 17, 2015, spike22 wrote: > Hi Eric, that's really interesting! I'll give it a whirl and report back > :) I might do a documentation pull request to clarify this too. > > Have a great day! > > Brendon > > On Friday, December 18, 2015 at 6:23:50

[Rails] Re: Why doesn't collection=objects on has_many :through trigger destroy callbacks on the join model?

2015-12-17 Thread spike22
Hi Eric, that's really interesting! I'll give it a whirl and report back :) I might do a documentation pull request to clarify this too. Have a great day! Brendon On Friday, December 18, 2015 at 6:23:50 AM UTC+13, Eric Krause wrote: > > I responded on stackoverflow, but I'll do here as well so

Re: [Rails] Re: Re: Use Polymorph or STI or.

2015-12-17 Thread Colin Law
On 17 December 2015 at 17:29, Travis Eubanks wrote: >> I have no idea what you are asking here. Sorry. >> >> Colin > I meant using a case statement. Sorry that was very poorly worded. > > def which_expense_type(expense) > > case expense.expense_type > > when "Travel" > expense.gl_code = a

[Rails] Re: Re: Use Polymorph or STI or.

2015-12-17 Thread Travis Eubanks
> I have no idea what you are asking here. Sorry. > > Colin I meant using a case statement. Sorry that was very poorly worded. def which_expense_type(expense) case expense.expense_type when "Travel" expense.gl_code = arbitrary_number when "Parking" expense.gl_code = arbitrary_numb

[Rails] Re: Why doesn't collection=objects on has_many :through trigger destroy callbacks on the join model?

2015-12-17 Thread Eric Krause
I responded on stackoverflow, but I'll do here as well so that it is covered everywhere on the internet. In my case I was doing something similar to what you were doing and was running into the same issue with the join table being deleted instead of destroyed. I started looking through the cod

[Rails] Map ActiveRecord to external database

2015-12-17 Thread Daniel Ritter
Hi, Im writing a Plugin for redmine. My Problem is to map an ActiveRecord to an external database. Here's my class: -- class FtpUser < ActiveRecord::Base attr_accessor :created_at, :password; attr_writer :uid, :gid; attr_reader :user, :

Re: [Rails] Re: Use Polymorph or STI or.

2015-12-17 Thread Colin Law
On 17 December 2015 at 12:25, Travis Eubanks wrote: >> It might be worth using STI but I would start the simple way and see >> how it pans out. Refactoring for that sort of change should not be >> difficult. >> >> You might want to consider having expense_type as a table so that you >> can add ex

[Rails] Re: Use Polymorph or STI or.

2015-12-17 Thread Travis Eubanks
> It might be worth using STI but I would start the simple way and see > how it pans out. Refactoring for that sort of change should not be > difficult. > > You might want to consider having expense_type as a table so that you > can add expense types without changing the code. Expense belongs_to