Hey guys I''m new here, I hope, theres someone who can help me because I asked this question on a lot of different platforms on the internet and there was noone who could give me a helpful answer. My problem is actually very simple: I know there is the command "rails g model" or rather "rails g migration" for changing or creating tables. But how can I let my controller AUTOMATICALLY create or change tables? Is there a ruby command that can create new tables such as "CREATE TABLE" in SQL? I''m looking for an answer to this question for so long, if there is someone who knows the answer, please write a comment. Thank you for your time, Anton -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/wEfX3bB_v0QJ. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2013-Apr-28 14:50 UTC
Re: How to create new tables while running (automatically)
On 28 April 2013 12:31, Anton Kanter <proghix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey guys > > I''m new here, I hope, theres someone who can help me because I asked this > question on a lot of different platforms on the internet and there was noone > who could give me a helpful answer. > My problem is actually very simple: I know there is the command "rails g > model" or rather "rails g migration" for changing or creating tables. But > how can I let my controller AUTOMATICALLY create or change tables? Is there > a ruby command that can create new tables such as "CREATE TABLE" in SQL? I''m > looking for an answer to this question for so long, if there is someone who > knows the answer, please write a comment.Which bit don''t you know how to do? Run sql directly from Rails or don''t you know the sql to create a table? Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
You can execute SQL statements in a rails application with the command: ActiveRecord::Base.connection.execute(''your sql'') http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#method-i-execute On Sunday, April 28, 2013 7:31:41 AM UTC-4, Anton Kanter wrote:> > Hey guys > > I''m new here, I hope, theres someone who can help me because I asked this > question on a lot of different platforms on the internet and there was > noone who could give me a helpful answer. > My problem is actually very simple: I know there is the command "rails g > model" or rather "rails g migration" for changing or creating tables. But > how can I let my controller AUTOMATICALLY create or change tables? Is there > a ruby command that can create new tables such as "CREATE TABLE" in SQL? > I''m looking for an answer to this question for so long, if there is someone > who knows the answer, please write a comment. > > Thank you for your time, > > Anton >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/fPDv_ZltZHkJ. For more options, visit https://groups.google.com/groups/opt_out.