--
Posted via http://www.ruby-forum.com/.
If you have a table widgets then all you need for the model is a file
models/widget.rb containing
class Widget < ActiveRecord::Base
end
Rails will do the rest.
Colin
Please don't top post, it makes it difficult to follow the thread,
insert your reply at appropriate points in previous message. Thanks.
> @colin : i haven't understand, can you explain how to make it. may be
> script for generate it like if i want generate controller (ruby
> script/generate ...)
Can you explain exactly what it is you are trying to generate. You
said that you wanted the model, is it actually the complete scaffold
that you want?
I think you can use the scaffold generator and pass it the option
--skip-migration to stop it making a migration to create the database,
but you still have to pass the fields you are interested in. I have
never done this however.
http://guides.rubyonrails.org/getting_started.html#getting-up-and-running-quickly-with-scaffolding
explains how to use the scaffold generator.
Colin
I asked last time that you don't top post, it makes it difficult to
follow the thread,
insert your reply at appropriate points in previous message. This
time you have not even quoted the previous message so anyone reading
this will have not idea what you are talking about without looking
back through the thread.
You say that you want to generate just the model, so you do not want
to generate the full scaffold. As I said previously there is no need
to "generate" the model, just create a file models/your_model.rb with
the class definition in as I showed in my first reply. Rails will
automatically pick up the fields from the database at run time.
I think you might benefit from reading through the Rails Guides and
from working through some tutorials. railstutorial.org is good and
free to use online. Make sure that you have the version of rails to
match the tutorial you are using.
Colin
Thanks colin, for your advice :) and your coment
--
Posted via http://www.ruby-forum.com/.
Can you just get a list of the columns in that table, then generate
the scaffold normally, using those fields as the parameters to the
call, then delete the migration file?
this gem might also have things you can use
https://github.com/amatsuda/hocus_pocus
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/C6b9xZ_D5rsJ.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-ta...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>