Hii friends,,,,,i m new to rails.i think there is a problem in destroy command

let me explain this problem …
-------------------rails destroy----------------------------this command
destroy model,scaffold etc …
problem is that if a model or other structure is exist than ,this
command
will destroy all the related file to it…good …till now no
problem…
but problem is that if a model etc is not exist than till this command
remove the file …it should not be done…there is no such a file
name
exist…
some error or exception should be execute at this time …

i think this a problem???
if not than expalin me…

Regards
Fahim Babar Patel

On 16 August 2012 06:03, Fahim P. [email protected] wrote:

i think this a problem???
if not than expalin me…

I am not sure what you are saying. Can you post an example and the
result and explain what you think should happen. Run the command and
copy and paste the result here. Showing an example is always better
than trying to explain it in words in a languaget that is not your
first language.

Colin

Are you saying to run rails destroy model foo and foo doesn’t exist then
you should get an error or exception message? If you try this on the
command line rails destroy model foo, it will run the opposite of the
generate command; however, nothing ever existed, so can’t see the harm.

On Thu, Aug 16, 2012 at 3:09 PM, AmateurCoder
[email protected]wrote:

command destroy model,scaffold etc …

The behaviour is consistent with other commands. If, for example, you
run
‘rake db:migrate’ and there are no migrations that need to be run, the
task
simply returns you to the command line without comment. One might make
the
argument that it should say something like ‘there are no migrations
that
need to be run.’ Or one might start submitting patches and see what the
community thinks :wink:

Best regards,
Bill

i am waiting for ur reply Rails Community…can any one tell that this
issue is problem or not???i think it is a problem…some exception
should be thrown or any message…
this command removing the files which are not exist…i know this
issue is not a error …but it make a confussion…
waiting for ur reply
Fahim Babar Patel

can one explain this issue?

thanks for reply…let me explain …

there is no such a testing model present
rails destroy model testing
invoke active_record
remove migration.rb
remove app/models/testing.rb
invoke rspec
remove spec/models/testing_spec.rb
invoke factory_girl
remove spec/factories/testings.rb

but it is still removing files…

one more example
rails destroy controller testing
remove app/controllers/testing_controller.rb
invoke erb
remove app/views/testing
invoke rspec
remove spec/controllers/testing_controller_spec.rb
invoke helper
remove app/helpers/testing_helper.rb
invoke rspec
remove spec/helpers/testing_helper_spec.rb
invoke assets
invoke coffee
remove app/assets/javascripts/testing.js.coffee
invoke scss
remove app/assets/stylesheets/testing.css.scss

there is no testing controller prsent…
this thing is happen with all directory structure…
scaffold also do the same thing…

there should be any exception or error ???

On 31 August 2012 15:03, Fahim P. [email protected] wrote:

but problem is that if a model etc is not exist than till this command
remove the file …it should not be done…there is no such a file name
exist…
some error or exception should be execute at this time …

i think this a problem???
if not than expalin me…

I think the most likely cause is that the keys on your keyboard are
sticking down causing all the repeated characters.

If you are referring to the fact that rails destroy attempts to delete
all the files that generate creates then that is just the way it is.
I don’t think anyone really cares much how rails destroy works as it
is virtually never used. I don’t think I have ever used it. If you
want to remove stuff you can just delete the files you don’t want.

Colin

i have given a code snippet .
u can watch it .
i think this the big issue

On Friday, 31 August 2012 09:03:40 UTC-5, Fahim P. wrote:

problem…
but problem is that if a model etc is not exist than till this command
remove the file …it should not be done…there is no such a file name
exist…
some error or exception should be execute at this time …

i think this a problem???
if not than expalin me…

It’s not deleting anything. Even though it claims it is it’s just cruft
in
the terminal. It’s impossible to delete something that doesn’t exist,
well
I should not say impossible as anything is possible but none-the-less
the
cruft is still outputted even if it does not delete anything. Perhaps
you
should file a rails bug and ask them to adjust the message to imply
“trying” instead of implying “doing”.

On 1 September 2012 12:12, Fahim P. [email protected] wrote:

i have given a code snippet .
u can watch it .
i think this the big issue

Why do you think it is a big issue?

Colin

On Friday, 17 August 2012 01:19:52 UTC-4, Fahim P. wrote:

  remove    app/helpers/testing_helper.rb

scaffold also do the same thing…

there should be any exception or error ???

No - the generator output is (slightly) confusing, but raising an
exception
in these cases would mean that you wouldn’t be able to use ‘destroy’ to
clean up after a generator if you’d manually removed any of the files it
had created.

–Matt J.