Hi,
Anything between back ticks (`) in Ruby will be run on the command
line.
So say, your ajax posts to an action called create_model
def create_model
if params[:new_model]
`script/generate model #{params[:new_model}`
end
end
That would create a new blank model file with the name passed to it as
the parameter new_model. If the correct table exists, your model would
work like normal.
When Rails creates a new model, it create a new migration file. If you
also needed to create a new blank table for the new model.
`rake db:migrate`
Although, the table will be created, at this stage the table will have
no fields. Adding fields to the model .. well that would probably
require you to tap into
ActiveRecord::Migration.add_column(table_name, column_name, type)
Luke
On Jun 20, 11:04 am, Shyam Vijayakumar <rails-mailing-l...@andreas-
s.net> wrote:> Hi,
> I need to know how to make a new model using user generated input
> about the name of the model and the schema. I''m fairly new to ror,
so I
> don''t even know if it''s possible. My friend said you can
do this using
> prototype and script.aculo.us ajax libraries but from the tutorials
I''ve
> seen, none of them mention anything about being able to create models on
> the fly. If this is not possible with ajax, then please direct me
> towards the correct topic I should look into.
>
> Thanks.
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---