Ruby on Rails Thursday, January 19, 2017

In my application whenever I try to start rails server following warning pop-up

/home/deepak/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51:
warning: constant ::Fixnum is deprecated
/home/deepak/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52:
warning: constant ::Bignum is deprecated
=> Booting Puma
=> Rails 5.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
/home/deepak/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/core_ext/numeric/conversions.rb:138:
warning: constant ::Fixnum is deprecated
Puma starting in single mode...
* Version 3.6.2 (ruby 2.4.0-p0), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop


Is it something from backend or I'm missing something to install on my
machine which produce this.

--
Cheers!

Deepak Kumar Sharma

--
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@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CALDHwN62%3DX5Ydd4FdE7Wv13ZEH4P8yuapxWtNdA9OnFRpzz2-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hey David,

Devise has an additional constraint named unauthenticated which you can use to restrict access to routes for a logged in user.

For example,

authenticated :user do
   root 'hub#index', as: :authenticated_root
end

unauthenticated :user do
   # place routes for unauthenticated users only here
   resources :welcomes
end

What you'll find is that now if the user tries to navigate to the /welcomes path while logged in, the route will be undefined. 

Documentation is here:

Hope that helps!

On Thursday, January 19, 2017 at 11:56:45 AM UTC-5, David Williams wrote:
The authenticated user root path works perfectly. What I'm trying to do is stop the user from returning back to the root 'welcome#index' after login?

authenticated :user do
root 'hub#index', as: :authenticated_root
end

# How can I stop users from going back to root 'welcome#index' after they've logged in.

--
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@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7629f4cc-24d7-41db-8add-ad9f615a44af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

This is for your seed file. You can create a task for it as well.

On Thursday, January 19, 2017 at 11:59:48 AM UTC-5, David Williams wrote:
vocabularies = File.read(Rails.root.join('lib', 'seeds', 'words.csv'))
csv = CSV.parse(vocabularies, :headers => true, :encoding => 'ISO-8859-1')
csv.each do |row|
t = Vocabulary.new
t.
word_column1 = row[0]
t.word_column2 = row[1]
t.word_column3 = row[2]
t.word_column4 = row[3]
t.word_column5 = row[4]
t.save!
puts
"#{t.word_column1}, #{t.word_column2} saved"
end

On Sunday, January 15, 2017 at 3:21:54 AM UTC-5, parzival wade wrote:
Hi Daynthan,

I have the same problem. So I see you got working solution.
Please, can you post final version of working important files?
Thank you.

On Friday, January 6, 2017 at 2:45:29 PM UTC+1, daynthan kabilan wrote:
Thank you Tamosus pontik.

I have done the task using this keyword require "#{dynamic_model_name}"

On Thu, Jan 5, 2017 at 7:24 PM, tamouse pontiki <tamous...@gmail.com> wrote:
On Thu, Jan 5, 2017 at 2:40 AM Daynthan Kabilan <dayan...@gmail.com> wrote:
Hi Tamosus pontik,

Thanks for your reply.
The model file is created dynamically based on this code.

And after you write that file, you need to require it for Rails to use it. That's why the constant is undefined.
 
Do you know how the require statement works in Ruby?


 model_file = File.join("app", "models", fname.singularize+".rb")
    model_name = fname.singularize.capitalize
    File.open(model_file, "w+") do |f|
      f << "class #{model_name} < ActiveRecord::Base\nend"
    end

But i need to store the values to specific tables. 
Note: I am not running migration for the dynamic tables(model)

On Wed, Jan 4, 2017 at 10:07 PM, tamouse pontiki <tamous...@gmail.com> wrote:


On Wed, Jan 4, 2017 at 8:57 AM Daynthan Kabilan <dayan...@gmail.com> wrote:
Hi,

I have a CSV upload option and need to create a table and model based on the CSV colums.

We allow to upload different kind of CSV file formats and each file upload will create new table and info will be stored accordingly. I have created a table with columns based on CSV file header and also created a model base on CSV file name.  But when i store the file details to specific table i faced error. 


def self.import(file, head, csvalue,fname)

...............
..............

ActiveRecord::Schema.define do
      create_table "#{fname}" do |t|
        #(define your columns just as you would in a migration file)
        head.each do |h|
          t.text h
        end
        # t.string :my_string
      end
    end

  model_file = File.join("app", "models", fname.singularize+".rb")
    model_name = fname.singularize.capitalize
    File.open(model_file, "w+") do |f|
      f << "class #{model_name} < ActiveRecord::Base\nend"
    end

        # ss=model_name.new
    p   ss=model_name.constantize.new

..............
...............

file="#{fname}_#{cnt}"
return file
end


How can declare the object for dynamic model. Because I couldn't store the values to new table.

I faced the Error like NameError (uninitialized constant Mytest):

Any idea how to solve this ? 

I do not know if this will work, but you probably need to manually require the model file you create before you try to constantize the model name. I don't think Rails autoloading is working in this situation.

 
 

--
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-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADKeJyQKcRGM%3Dj3miANP9PqfODZ6fA8x98F8vUfG_QQ1KnEntw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHUC_t8QDyZZhv0Z4TANe1Zc7jcR%2BqYsW4iitPxLQz%3DGqXMpKw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
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@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f7ae5671-90d7-4da2-94e7-66dfdb0fba82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.