Wes Gamble
2006-May-24 17:38 UTC
[Rails] Analog to ruby script/generate for removing generated stuff?
All, If I do ruby script/generate model blah, is there an easy way for me to remove all of that stuff that got generated? Something like: ruby script/remove model blah? If it doesn''t exist, is it coming? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
Mike Oligny
2006-May-24 17:41 UTC
[Rails] Analog to ruby script/generate for removing generated stuff?
On 24-May-06, at 12:38 PM, Wes Gamble wrote:> All, > > If I do ruby script/generate model blah, > > is there an easy way for me to remove all of that stuff that got > generated?try script/destroy
Pat Maddox
2006-May-24 17:43 UTC
[Rails] Analog to ruby script/generate for removing generated stuff?
>On 5/24/06, Wes Gamble <weyus@att.net> wrote: > All, > > If I do ruby script/generate model blah, > > is there an easy way for me to remove all of that stuff that got > generated? > > Something like: > > ruby script/remove model blah? > > If it doesn''t exist, is it coming? > > Thanks, > Wes > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >rm models/blah.rb rm test/fixtures/blahs.yml rm test/unit/blah_test.rb The generator is nice because it creates a lot of code in addition to the files. Removing the model is as simple as deleting those three files. You''ll of course have to remove references elsewhere - but that certainly should not be done automatically. Pat
Pat Maddox
2006-May-24 17:48 UTC
[Rails] Analog to ruby script/generate for removing generated stuff?
On 5/24/06, Mike Oligny <mike@schema.ca> wrote:> On 24-May-06, at 12:38 PM, Wes Gamble wrote: > > > All, > > > > If I do ruby script/generate model blah, > > > > is there an easy way for me to remove all of that stuff that got > > generated? > > try script/destroy > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >That will delete all the files created by the generator, which will screw with your migrations. Pat
Ben Wyrosdick
2006-May-25 03:05 UTC
[Rails] Analog to ruby script/generate for removing generated stuff?
script/destroy shouldn''t mess up any migrations ... if you typed ''script/generate model blah'' then you should type ''script/destroy model blah'' and it will only delete the files added by the generate On 5/24/06, Pat Maddox <pergesu@gmail.com> wrote:> > On 5/24/06, Mike Oligny <mike@schema.ca> wrote: > > On 24-May-06, at 12:38 PM, Wes Gamble wrote: > > > > > All, > > > > > > If I do ruby script/generate model blah, > > > > > > is there an easy way for me to remove all of that stuff that got > > > generated? > > > > try script/destroy > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > That will delete all the files created by the generator, which will > screw with your migrations. > > Pat > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060525/7255bf06/attachment.html
Pat Maddox
2006-May-25 03:12 UTC
[Rails] Analog to ruby script/generate for removing generated stuff?
> On 5/24/06, Pat Maddox <pergesu@gmail.com> wrote: > > On 5/24/06, Mike Oligny <mike@schema.ca> wrote: > > > On 24-May-06, at 12:38 PM, Wes Gamble wrote: > > > > > > > All, > > > > > > > > If I do ruby script/generate model blah, > > > > > > > > is there an easy way for me to remove all of that stuff that got > > > > generated? > > > > > > try script/destroy > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > That will delete all the files created by the generator, which will > > screw with your migrations. > > > > Pat > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >On 5/24/06, Ben Wyrosdick <ben.wyrosdick@gmail.com> wrote: > script/destroy shouldn''t mess up any migrations ... if you typed > ''script/generate model blah'' then you should type ''script/destroy model > blah'' and it will only delete the files added by the generate > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >"it will only delete the files added by the generate" - which includes a migration file. baggio:~/work/test_app pergesu$ ./script/generate model Foo exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/foo.rb create test/unit/foo_test.rb create test/fixtures/foos.yml exists db/migrate create db/migrate/001_create_foos.rb baggio:~/work/test_app pergesu$ ./script/destroy model Foo notempty db/migrate notempty db rm db/migrate/001_create_foos.rb rm test/fixtures/foos.yml rm test/unit/foo_test.rb rm app/models/foo.rb As you can see, the migration got deleted. This is fine if you just created a model and need to delete it, but I would not recommend destroying a model that''s got a migration somewhere in the middle. Just curious - is it really that difficult to rm three files? Pat
Mike Oligny
2006-May-25 03:14 UTC
[Rails] Analog to ruby script/generate for removing generated stuff?
On 24-May-06, at 10:12 PM, Pat Maddox wrote:> Just curious - is it really that difficult to rm three files?It''s two more (potentially dangerous) commands, yes.
Wes Gamble
2006-May-25 03:16 UTC
[Rails] Re: Analog to ruby script/generate for removing generated st
Pat Maddox wrote:>> On 5/24/06, Pat Maddox <pergesu@gmail.com> wrote: >> > > try script/destroy >> > _______________________________________________ >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> > > Just curious - is it really that difficult to rm three files? > > PatDefinitely not that difficult, but when I know I want the shortcut, I''d like to have it available. You''d be surprised how easy it is to screw typing 3 rm commands :) -- Posted via http://www.ruby-forum.com/.
Pat Maddox
2006-May-25 03:22 UTC
[Rails] Analog to ruby script/generate for removing generated stuff?
On 5/24/06, Mike Oligny <mike@schema.ca> wrote:> On 24-May-06, at 10:12 PM, Pat Maddox wrote: > > > Just curious - is it really that difficult to rm three files? > > It''s two more (potentially dangerous) commands, yes. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >script/destroy doesn''t work. I''ve shown why - it mucks with the migration as well. If you rm the wrong file, svn up it. Another problem with script/destroy is that it doesn''t perform the proper svn delete commands, so you''ll have to do those manually anyway, negating the protection from the "dangerous" commands you get from script/destroy. Pat
Kevin Olbrich
2006-May-25 03:28 UTC
[Rails] Analog to ruby script/generate for removing generatedstuff?
On Wednesday, May 24, 2006, at 9:22 PM, Pat Maddox wrote:>On 5/24/06, Mike Oligny <mike@schema.ca> wrote: >> On 24-May-06, at 10:12 PM, Pat Maddox wrote: >> >> > Just curious - is it really that difficult to rm three files? >> >> It''s two more (potentially dangerous) commands, yes. >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > >script/destroy doesn''t work. I''ve shown why - it mucks with the >migration as well. If you rm the wrong file, svn up it. Another >problem with script/destroy is that it doesn''t perform the proper svn >delete commands, so you''ll have to do those manually anyway, negating >the protection from the "dangerous" commands you get from >script/destroy. > >Pat >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsIf you call script/generate or script/destroy with the ''-c'' flag, it should do the proper subversion commands as well. I know it works for generate, but haven''t verified that for destroy. I also have issues with anything destroying migration files. Those should be removed manually, if at all. _Kevin -- Posted with http://DevLists.com. Sign up and save your mailbox.
Brian Hughes
2006-May-25 03:41 UTC
[Rails] Analog to ruby script/generate for removing generated stuff?
On May 24, 2006, at 11:22 PM, Pat Maddox wrote:> script/destroy doesn''t work. I''ve shown why - it mucks with the > migration as well. If you rm the wrong file, svn up it.I''m more or less with you, up to this point. Using script/destroy on models was a lot simpler before the migration file was auto-generated as well.> Another problem with script/destroy is that it doesn''t perform the > proper svn > delete commands, so you''ll have to do those manually anyway, negating > the protection from the "dangerous" commands you get from > script/destroy.This, however, is incorrect. Just like you can do: script/generate model -c Foo You can also do: script/destroy model -c Foo In fact, I use the -c option all the time. It''s really useful for cleaning up controllers, if not so great for models, because of the potential migration hassles. -Brian
Stephane Fourdrinier
2006-May-25 05:35 UTC
[Rails] model declaration. has_one. Best way of doing it?
I have 3 models: User: has_many :profiles has_one :defaultprofile, :class_name => "Profile", ......................... # WAY 1 ??????? has_one :defaultprofile, :class_name => "Profile", :conditions=>"isdefaultprofile=1" # WAY 2 Profile belongs_to :user belongs_to :profiletype Profiletype has_many :profiles Basically a user can have many profiles but only ONE is a default. I have 2 choices on where to store the information on what is a default profile: in User, with a field "defaultprofile_id" with profile.id as the key (WAY 1), *or* in Profiletype with a field "isdefaultprofile=0|1" (which also has a user_id=... field) (WAY 2) WAY 2 works fine I can''t seem to get WAY 1 to work... I would rather store the fact that it is a defaultprofile in the User model than in the Profile model as if I wish to change the defaultprofile as I would not have to worry if I put the definition in Profiles that there may be more than one profile that is a defaultprofile.Meaning that with WAY 2 if I wish to change the default profile of a User I would have to first clear the isdefaultprofile for all the profiles associated with that user and only set one to 1. It means, 2 operations. Where as, WAY1 as i see it would be a simple one operation. User.defaultprofile_id=profile.id Anyone has any suggestions? I can''t seem to be able to get this "WAY 1" to work as I intend. Stephane -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060525/631b2148/attachment.html
Wes Gamble
2006-May-25 05:48 UTC
[Rails] Re: Analog to ruby script/generate for removing generated st
Brian Hughes wrote:> On May 24, 2006, at 11:22 PM, Pat Maddox wrote: >> script/destroy doesn''t work. I''ve shown why - it mucks with the >> migration as well. If you rm the wrong file, svn up it. > > I''m more or less with you, up to this point. Using script/destroy on > models was a lot simpler before the migration file was auto-generated > as well. > >> Another problem with script/destroy is that it doesn''t perform the >> proper svn >> delete commands, so you''ll have to do those manually anyway, negating >> the protection from the "dangerous" commands you get from >> script/destroy. > > This, however, is incorrect. Just like you can do: > > script/generate model -c Foo > > You can also do: > > script/destroy model -c Foo > > In fact, I use the -c option all the time. It''s really useful for > cleaning up controllers, if not so great for models, because of the > potential migration hassles. > > -BrianDoes -c only work for subversion or could I use it with cvs as well? Wes -- Posted via http://www.ruby-forum.com/.
Maybe Matching Threads
- The RoR equivalent of out.write() in JSP?
- Edge RSpec on Rails...what did I forget?
- [PLUGIN] rspec_resource_generator - RESTful scaffold generator with RSpec specifications
- What''s the new syntax for predicates?
- it "should [action] ..." vs it with an active voice