[Rails] Dynamically create databases?

2013-04-04 Thread Johan Vauhkonen
Is it possible to dynamically create new databases and tables within them 
with Rails?

Or is that a task best done manually?

I'm creating an application which should allow users to store their own 
statistics information (which can and probably with time will be a lot).
My initial thought was to give each user their own database to keep their 
data separate from each other due to the possible large quantity of data 
each user will have.

Good idea? Bad idea? Other ways to do it?

-- 
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+unsubscr...@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/msg/rubyonrails-talk/-/ZRLrcnKJ-fsJ.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Help with single page application structure

2013-04-04 Thread Johan Vauhkonen
I think for me, using Sinatra would mean I'd have to write a lot of things 
that Rails bring which I don't want to.

-- 
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+unsubscr...@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/msg/rubyonrails-talk/-/IaOIv-46b6EJ.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Dynamically create databases?

2013-04-04 Thread Julian Leviston
Yes, and yes.

That sounds fine.

Just be careful not to optimise prematurely (ie... make design decisions with a 
VIEW to the future, but don't let that both you too much in the present). 
Chances are when it comes to architecture and optimisation, Ya Aint Gonna Need 
It, and when you do, it'll most likely be different than you think it will be 
now.

Focus more on the classes in your system than how to efficiently store them at 
the inception/design stage.

Julian

On 04/04/2013, at 5:29 PM, Johan Vauhkonen johan.vauhko...@gmail.com wrote:

 Is it possible to dynamically create new databases and tables within them 
 with Rails?
 
 Or is that a task best done manually?
 
 I'm creating an application which should allow users to store their own 
 statistics information (which can and probably with time will be a lot).
 My initial thought was to give each user their own database to keep their 
 data separate from each other due to the possible large quantity of data each 
 user will have.
 
 Good idea? Bad idea? Other ways to do it?
 
 -- 
 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+unsubscr...@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/msg/rubyonrails-talk/-/ZRLrcnKJ-fsJ.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Help me with :only in Route of Rails

2013-04-04 Thread Colin Law
On 4 April 2013 06:29, haxuan lac li...@ruby-forum.com wrote:
 I'm learning with routing in rails from :
 http://guides.rubyonrails.org/routing.html
 and I have first code : resources :users
 and last code:  resources :users, :only = [:index, :show]
 and have error :
 undefined method `edit_user_path' for ##Class:0x2d9d068:0x53dacb0

Your :only spec says that only index and show are valid user actions.
The error says that you have tried to use edit.  Either you need to
include :edit in the :only spec or you need to change the code that is
resulting in edit being actioned.

If you have not already done so then it would be worth working right
through a good tutorial such as railstutorial.org, which is free to
use online.  That will show you the basics of rails.

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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Dynamically create databases?

2013-04-04 Thread Johan Vauhkonen
Thanks for replying, Julian.

Can you point me to any resources that describe how to do it?

I agree that I should not optimize prematurely but what I'm considering is 
which is easier,
to go with dynamically creating databases from the start or to extract data 
from the single database to new databases later on?

It's at least something to keep in the back of my mind.

-- 
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+unsubscr...@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/msg/rubyonrails-talk/-/ItAsVSewcngJ.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Dynamically create databases?

2013-04-04 Thread Colin Law
On 4 April 2013 07:29, Johan Vauhkonen johan.vauhko...@gmail.com wrote:
 Is it possible to dynamically create new databases and tables within them
 with Rails?

 Or is that a task best done manually?

 I'm creating an application which should allow users to store their own
 statistics information (which can and probably with time will be a lot).
 My initial thought was to give each user their own database to keep their
 data separate from each other due to the possible large quantity of data
 each user will have.

 Good idea? Bad idea? Other ways to do it?

What do you mean by a large quantity of data?  Modern databases can
manage vast amounts of data efficiently.  It is very rare for the
bottlenecks in a system to be where you expect them to be when you
start out and it is very likely that you will find that the extra work
was a waste of time.  Start with a single database and make sure you
have good automated test coverage.  Then in the unlikely event that
you find that you do have split the database then you can refactor the
code and the tests will help to ensure that you have not messed
anything up.

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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] strange behavior with active relation any? method

2013-04-04 Thread DALVIR SINGH KHOSA
hola por favor yo quiero baja  rubyonrails-talk este ymail  gracias

On 03/04/2013, Colin Law clan...@googlemail.com wrote:
 On 3 April 2013 20:58, John Merlino stoici...@aol.com wrote:
 In console, I run the following and any? returns true:
 drivers = Driver.select(drivers.*,
 drivers.id).joins([:reports, :driving_habits]).where(extract(MONTH
 FROM reports.time) = ? AND extract(YEAR FROM reports.time) = ?, 3,
 2013).uniq.order(drivers.id asc).page(2).per(1)
 drivers.any?
  = true

 This correctly evaluates to true because the relation contains one
 returned record.

 However, I run the same query within the Rails app itself, and any?
 must evaluate @drivers in the view to either false or nil, because the
 else is triggered instead when I click on second page in view. What's
 even weirder is that when I call inspect on @drivers, then
 @drivers.any? is evaluated to true in the view when I click on the
 second page using kaminari:

 @drivers = Driver.select(drivers.*, #{sort_column})
 .joins([:reports, :driving_habits])
 .by_month(for_selected_month.to_i,
 for_selected_year.to_i)
 .order(sort_column +   + sort_direction)
 .page(params[:page]).per(1)

 puts The drivers #{@drivers.inspect}


 What's driving all this weird behavior?

 Can you show us the code where you perform the test that is failing?

 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+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Dynamically create databases?

2013-04-04 Thread Julian Leviston

On 04/04/2013, at 6:05 PM, Johan Vauhkonen johan.vauhko...@gmail.com wrote:

 Thanks for replying, Julian.
 
 Can you point me to any resources that describe how to do it?
 
 I agree that I should not optimize prematurely but what I'm considering is 
 which is easier,
 to go with dynamically creating databases from the start or to extract data 
 from the single database to new databases later on?
 
 It's at least something to keep in the back of my mind.

Hi,

You shouldn't attempt to do this if you don't already understand enough Ruby / 
Rails to do it yourself.

So, I suggest sticking with what you *can* do first.

This might sound like a cop out, but there's very good reason. It's very 
advanced Rails and you really shouldn't attempt something like this until you 
understand the basics really well IMHO.

Julian

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Dynamically create databases?

2013-04-04 Thread Johan Vauhkonen
Thanks for posting, I appreciate the feedback.

I'll start with keeping everything within a single database and take it
from there.

You are right Julian in that I am new with RoR and what I've asked for is
advanced.

I'm still curious though how creating databases dynamically would be done
so if it's explained anywhere I'd love to read it!


2013/4/4 Julian Leviston jul...@coretech.net.au


 On 04/04/2013, at 6:05 PM, Johan Vauhkonen johan.vauhko...@gmail.com
 wrote:

  Thanks for replying, Julian.
 
  Can you point me to any resources that describe how to do it?
 
  I agree that I should not optimize prematurely but what I'm considering
 is which is easier,
  to go with dynamically creating databases from the start or to extract
 data from the single database to new databases later on?
 
  It's at least something to keep in the back of my mind.

 Hi,

 You shouldn't attempt to do this if you don't already understand enough
 Ruby / Rails to do it yourself.

 So, I suggest sticking with what you *can* do first.

 This might sound like a cop out, but there's very good reason. It's very
 advanced Rails and you really shouldn't attempt something like this until
 you understand the basics really well IMHO.

 Julian

 --
 You received this message because you are subscribed to a topic in the
 Google Groups Ruby on Rails: Talk group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/rubyonrails-talk/S73DxPeqvy4/unsubscribe?hl=en-US
 .
 To unsubscribe from this group and all its topics, send an email to
 rubyonrails-talk+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Dynamically create databases?

2013-04-04 Thread Jeffrey Jones
Assuming you are using postgresql you might be interested in this 
railscast (paid)


http://railscasts.com/episodes/389-multitenancy-with-postgresql

Which takes advantage of being able to have multiple schemas in PostgreSQL.

Be aware though that it will make your initial coding more complicated 
and will

have knock-on effects for things like testing etc.

Basically, it will do what you want but it will not be free in terms of 
development effort.


I echo other statements that this may be premature optimisation, look at 
the railscast, give

it a try yourself and see if the trade-off is good enough for you.

(If you do not want to pay for railscasts then have a look at this gem: 
https://github.com/influitive/apartment)



On 04/04/13 16:43, Johan Vauhkonen wrote:

Thanks for posting, I appreciate the feedback.

I'll start with keeping everything within a single database and take 
it from there.


You are right Julian in that I am new with RoR and what I've asked for 
is advanced.


I'm still curious though how creating databases dynamically would be 
done so if it's explained anywhere I'd love to read it!



2013/4/4 Julian Leviston jul...@coretech.net.au 
mailto:jul...@coretech.net.au



On 04/04/2013, at 6:05 PM, Johan Vauhkonen
johan.vauhko...@gmail.com mailto:johan.vauhko...@gmail.com wrote:

 Thanks for replying, Julian.

 Can you point me to any resources that describe how to do it?

 I agree that I should not optimize prematurely but what I'm
considering is which is easier,
 to go with dynamically creating databases from the start or to
extract data from the single database to new databases later on?

 It's at least something to keep in the back of my mind.

Hi,

You shouldn't attempt to do this if you don't already understand
enough Ruby / Rails to do it yourself.

So, I suggest sticking with what you *can* do first.

This might sound like a cop out, but there's very good reason.
It's very advanced Rails and you really shouldn't attempt
something like this until you understand the basics really well IMHO.

Julian

--
You received this message because you are subscribed to a topic in
the Google Groups Ruby on Rails: Talk group.
To unsubscribe from this topic, visit

https://groups.google.com/d/topic/rubyonrails-talk/S73DxPeqvy4/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email
to rubyonrails-talk+unsubscr...@googlegroups.com
mailto:rubyonrails-talk%2bunsubscr...@googlegroups.com.
To post to this group, send email to
rubyonrails-talk@googlegroups.com
mailto:rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
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+unsubscr...@googlegroups.com.

To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




--
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Dynamically create databases?

2013-04-04 Thread Julian Leviston
Okay...

So to do this, you need to understand meta-programming to a degree because 
that's what you're doing.

In normal Rails, you'd create a model as part of the development process, but 
what you're doing is creating some code that creates models itself (ie one 
level of abstraction higher than normal).

The equivalent straight ruby comparison is: (compare 1, with 2, below):

1. Creating a class (this is normal programming)

class Cat
  def hi
puts 'meow'
  end
end

You can then create new Cat objects like this:
furrycat = Cat.new

and make it meow like this:
furrycat.hi

2. Creating a piece of code that creates a class (this is meta-programming)

a_class = Class.new
hi_method_block = Proc.new{ puts 'meow' }
a_class.send(:define_method, :hi, hi_method_block)

You can then create new Cat objects like this:
furrycat = a_class.new

and make it meow like this:
furrycat.hi

---

So...  assuming you followed that, then you'll understand that you could do the 
same thing with ActiveRecord::Base classes, which is what forms the bases for 
Active Record model classes. This is how you'd dynamically LOAD one of your 
programmatically generated models. Creating the table is just a matter of 
executing some arbitrary SQL which can be built using 
ActiveRecord::Base.connection.execute. (Eg to run a count of a fictitious users 
table, you'd do this: ActiveRecord::Base.connection.execute(SELECT COUNT(*) 
FROM users;)

However, like I said, there's no point trying to do this until you can walk, 
because this really is running. Most Rails devs hardly ever get into this 
stuff. I've been a Rails developer since 2005, and I've only done this sort of 
dynamic table and database thing once or twice in practice.

Julian

On 04/04/2013, at 6:43 PM, Johan Vauhkonen johan.vauhko...@gmail.com wrote:

 Thanks for posting, I appreciate the feedback.
 
 I'll start with keeping everything within a single database and take it from 
 there.
 
 You are right Julian in that I am new with RoR and what I've asked for is 
 advanced.
 
 I'm still curious though how creating databases dynamically would be done so 
 if it's explained anywhere I'd love to read it!
 
 
 2013/4/4 Julian Leviston jul...@coretech.net.au
 
 On 04/04/2013, at 6:05 PM, Johan Vauhkonen johan.vauhko...@gmail.com wrote:
 
  Thanks for replying, Julian.
 
  Can you point me to any resources that describe how to do it?
 
  I agree that I should not optimize prematurely but what I'm considering is 
  which is easier,
  to go with dynamically creating databases from the start or to extract data 
  from the single database to new databases later on?
 
  It's at least something to keep in the back of my mind.
 
 Hi,
 
 You shouldn't attempt to do this if you don't already understand enough Ruby 
 / Rails to do it yourself.
 
 So, I suggest sticking with what you *can* do first.
 
 This might sound like a cop out, but there's very good reason. It's very 
 advanced Rails and you really shouldn't attempt something like this until you 
 understand the basics really well IMHO.
 
 Julian
 
 --
 You received this message because you are subscribed to a topic in the Google 
 Groups Ruby on Rails: Talk group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/rubyonrails-talk/S73DxPeqvy4/unsubscribe?hl=en-US.
 To unsubscribe from this group and all its topics, send an email to 
 rubyonrails-talk+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
 
 -- 
 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+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: Help me with :only in Route of Rails

2013-04-04 Thread haxuan lac
Thanks Colin.
I'm learning step by step Ruby on Rails with Railstutorial.org
I solved my problem.

-- 
Posted via http://www.ruby-forum.com/.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Dynamically create databases?

2013-04-04 Thread Simon Macneall
We have toyed with creating separate databases for each customer as our  
combined one is starting to get quite large. In our case, the models will  
always be the same no matter which database you are connecting to, so  
there isn't any meta-programming involved. It's just a case of switching  
databases to the correct one for that customer once they log into the  
system.


One thing to consider is that shared data needs to go somewhere (sessions,  
username/passwords etc) as well.


Cheers
Simon





On Thu, 04 Apr 2013 16:34:21 +0800, Julian Leviston  
jul...@coretech.net.au wrote:



Okay...

So to do this, you need to understand meta-programming to a degree  
because that's what you're doing.


In normal Rails, you'd create a model as part of the development  
process, but what you're doing is creating some code that creates models  
itself (ie one level of abstraction higher than normal).


The equivalent straight ruby comparison is: (compare 1, with 2, below):

1. Creating a class (this is normal programming)

class Cat
  def hi
puts 'meow'
  end
end

You can then create new Cat objects like this:
furrycat = Cat.new

and make it meow like this:
furrycat.hi

2. Creating a piece of code that creates a class (this is  
meta-programming)


a_class = Class.new
hi_method_block = Proc.new{ puts 'meow' }
a_class.send(:define_method, :hi, hi_method_block)

You can then create new Cat objects like this:
furrycat = a_class.new

and make it meow like this:
furrycat.hi

---

So...  assuming you followed that, then you'll understand that you could  
do the same thing with ActiveRecord::Base classes, which is what forms  
the bases for Active Record model classes. This is how you'd dynamically  
LOAD one of your programmatically generated models. Creating the table  
is just a matter of executing some arbitrary SQL which can be built  
using ActiveRecord::Base.connection.execute. (Eg to run a count of a  
fictitious users table, you'd do this:  
ActiveRecord::Base.connection.execute(SELECT COUNT(*) FROM users;)


However, like I said, there's no point trying to do this until you can  
walk, because this really is running. Most Rails devs hardly ever get  
into this stuff. I've been a Rails developer since 2005, and I've only  
done this sort of dynamic table and database thing once or twice in  
practice.


Julian

On 04/04/2013, at 6:43 PM, Johan Vauhkonen johan.vauhko...@gmail.com  
wrote:



Thanks for posting, I appreciate the feedback.

I'll start with keeping everything within a single database and take it  
from there.


You are right Julian in that I am new with RoR and what I've asked for  
is advanced.


I'm still curious though how creating databases dynamically would be  
done so if it's explained anywhere I'd love to read it!



2013/4/4 Julian Leviston jul...@coretech.net.au

On 04/04/2013, at 6:05 PM, Johan Vauhkonen johan.vauhko...@gmail.com  
wrote:


 Thanks for replying, Julian.

 Can you point me to any resources that describe how to do it?

 I agree that I should not optimize prematurely but what I'm  
considering is which is easier,
 to go with dynamically creating databases from the start or to  
extract data from the single database to new databases later on?


 It's at least something to keep in the back of my mind.

Hi,

You shouldn't attempt to do this if you don't already understand enough  
Ruby / Rails to do it yourself.


So, I suggest sticking with what you *can* do first.

This might sound like a cop out, but there's very good reason. It's  
very advanced Rails and you really shouldn't attempt something like  
this until you understand the basics really well IMHO.


Julian

--
You received this message because you are subscribed to a topic in the  
Google Groups Ruby on Rails: Talk group.
To unsubscribe from this topic, visit  
https://groups.google.com/d/topic/rubyonrails-talk/S73DxPeqvy4/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to  
rubyonrails-talk+unsubscr...@googlegroups.com.

To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




--
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+unsubscr...@googlegroups.com.

To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




--
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Error in controller Namespace of Route --Rails

2013-04-04 Thread haxuan lac
I'm trying to work with controller Namespace of Route.
i'm doing with instructions in :
http://guides.rubyonrails.org/routing.html
and here is code of my Route:

namespace :admin do
  resources :users
 end

I created admin folder admin and move controller users_controller to it.
And I edit code in users_controller same as :

class Admin::UsersController  ApplicationController
But when I ran project and using Url:

http://localhost:3000/admin/users/new
and have error:

Missing template admin/users/new, application/new with {:locale=[:en],
:formats=[:html], :handlers=[:erb, :builder, :coffee]}.
Who can help me this problem ? Thanks...

-- 
Posted via http://www.ruby-forum.com/.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Dynamically create databases?

2013-04-04 Thread Johan Vauhkonen
That kind of scenario was what I had initially in mind. Everyone has
the same models, just not the same database.

2013/4/4, Simon Macneall macne...@gmail.com:
 We have toyed with creating separate databases for each customer as our
 combined one is starting to get quite large. In our case, the models will
 always be the same no matter which database you are connecting to, so
 there isn't any meta-programming involved. It's just a case of switching
 databases to the correct one for that customer once they log into the
 system.

 One thing to consider is that shared data needs to go somewhere (sessions,

 username/passwords etc) as well.

 Cheers
 Simon





 On Thu, 04 Apr 2013 16:34:21 +0800, Julian Leviston
 jul...@coretech.net.au wrote:

 Okay...

 So to do this, you need to understand meta-programming to a degree
 because that's what you're doing.

 In normal Rails, you'd create a model as part of the development
 process, but what you're doing is creating some code that creates models

 itself (ie one level of abstraction higher than normal).

 The equivalent straight ruby comparison is: (compare 1, with 2, below):

 1. Creating a class (this is normal programming)

 class Cat
   def hi
 puts 'meow'
   end
 end

 You can then create new Cat objects like this:
 furrycat = Cat.new

 and make it meow like this:
 furrycat.hi

 2. Creating a piece of code that creates a class (this is
 meta-programming)

 a_class = Class.new
 hi_method_block = Proc.new{ puts 'meow' }
 a_class.send(:define_method, :hi, hi_method_block)

 You can then create new Cat objects like this:
 furrycat = a_class.new

 and make it meow like this:
 furrycat.hi

 ---

 So...  assuming you followed that, then you'll understand that you could

 do the same thing with ActiveRecord::Base classes, which is what forms
 the bases for Active Record model classes. This is how you'd dynamically

 LOAD one of your programmatically generated models. Creating the table
 is just a matter of executing some arbitrary SQL which can be built
 using ActiveRecord::Base.connection.execute. (Eg to run a count of a
 fictitious users table, you'd do this:
 ActiveRecord::Base.connection.execute(SELECT COUNT(*) FROM users;)

 However, like I said, there's no point trying to do this until you can
 walk, because this really is running. Most Rails devs hardly ever get
 into this stuff. I've been a Rails developer since 2005, and I've only
 done this sort of dynamic table and database thing once or twice in
 practice.

 Julian

 On 04/04/2013, at 6:43 PM, Johan Vauhkonen johan.vauhko...@gmail.com
 wrote:

 Thanks for posting, I appreciate the feedback.

 I'll start with keeping everything within a single database and take it

 from there.

 You are right Julian in that I am new with RoR and what I've asked for
 is advanced.

 I'm still curious though how creating databases dynamically would be
 done so if it's explained anywhere I'd love to read it!


 2013/4/4 Julian Leviston jul...@coretech.net.au

 On 04/04/2013, at 6:05 PM, Johan Vauhkonen johan.vauhko...@gmail.com
 wrote:

  Thanks for replying, Julian.
 
  Can you point me to any resources that describe how to do it?
 
  I agree that I should not optimize prematurely but what I'm
 considering is which is easier,
  to go with dynamically creating databases from the start or to
 extract data from the single database to new databases later on?
 
  It's at least something to keep in the back of my mind.

 Hi,

 You shouldn't attempt to do this if you don't already understand enough

 Ruby / Rails to do it yourself.

 So, I suggest sticking with what you *can* do first.

 This might sound like a cop out, but there's very good reason. It's
 very advanced Rails and you really shouldn't attempt something like
 this until you understand the basics really well IMHO.

 Julian

 --
 You received this message because you are subscribed to a topic in the
 Google Groups Ruby on Rails: Talk group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/rubyonrails-talk/S73DxPeqvy4/unsubscribe?hl=en-US.
 To unsubscribe from this group and all its topics, send an email to
 rubyonrails-talk+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




 --
 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+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.



 --
 You received this message because you are subscribed to a topic in the
 Google Groups Ruby on Rails: Talk group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/rubyonrails-talk/S73DxPeqvy4/unsubscribe?hl=en-US.
 To unsubscribe from this group 

[Rails] What is Javascript-Runtime for?

2013-04-04 Thread Peter
Hello Everyone,

Can anyone please describe the relationship of javascript-runtime to Ruby 
on Rails? In Mac OSX, I do not get this error, but in Linux for every new 
project generated by rails new, I get:

 play$ rails s

 //.rvm/gems/ruby-2.0.0-p0/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in 
 `autodetect': Could not find a JavaScript runtime. See 
 https://github.com/sstephenson/execjs for a list of available runtimes.


I know the solution; either install therubyracer or nodejs gems. But I am 
not sure I understand fully *why* it works. If I install this in a 
production environment server, I do not need either one of these. And my 
browser definitely interprets javascript built in. So how does this fit in 
to everything? Is my premise incorrect? Thank you.

Peter

-- 
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+unsubscr...@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/msg/rubyonrails-talk/-/T4-gAil4yQoJ.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Help with single page application structure

2013-04-04 Thread tamouse mailing lists
On Apr 4, 2013 1:35 AM, Johan Vauhkonen johan.vauhko...@gmail.com wrote:

 I think for me, using Sinatra would mean I'd have to write a lot of
things that Rails bring which I don't want to

Agreed; we were talking alternatives and for his needs, he really only
needed the pipeline.I was just trying to illustrate that stripping Rails
isn't the only direction one can go.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Help with single page application structure

2013-04-04 Thread Johan Vauhkonen
Is it a viable alternative to separate client and back end?

To have AngularJS take care of everything client side and Rails take care 
of only the back end?

-- 
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+unsubscr...@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/msg/rubyonrails-talk/-/ougmJcF-FxEJ.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Help with single page application structure

2013-04-04 Thread tamouse mailing lists
On Apr 4, 2013 7:20 AM, Johan Vauhkonen johan.vauhko...@gmail.com wrote:

 Is it a viable alternative to separate client and back end?

 To have AngularJS take care of everything client side and Rails take care
of only the back end?


Absolutely, you can go so far as to have your SPA initial download be a
static index.HTML in ../public, and just have your routes speak JSON to the
Angular requests. I'm working on this currently only using backbone and
underscore.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: What is Javascript-Runtime for?

2013-04-04 Thread Frederick Cheung


On Thursday, April 4, 2013 1:14:01 PM UTC+1, Peter wrote:

 Hello Everyone,

 Can anyone please describe the relationship of javascript-runtime to Ruby 
 on Rails? In Mac OSX, I do not get this error, but in Linux for every new 
 project generated by rails new, I get:

 play$ rails s

 //.rvm/gems/ruby-2.0.0-p0/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in 
 `autodetect': Could not find a JavaScript runtime. See 
 https://github.com/sstephenson/execjs for a list of available runtimes.


 I know the solution; either install therubyracer or nodejs gems. But I am 
 not sure I understand fully *why* it works. If I install this in a 
 production environment server, I do not need either one of these. And my 
 browser definitely interprets javascript built in. So how does this fit in 
 to everything? Is my premise incorrect? Thank you.


There are asset pipeline dependencies here: for example uglifyjs (for 
minifying javascript) and coffeescript are both written in javascript. Both 
of these two things happen serverside (almost: you can compile the assets 
somewhere other than your deployment machines, and copy the finished 
product either to the deployment machines or to the CDN of your choice)

Fred

-- 
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+unsubscr...@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/msg/rubyonrails-talk/-/uC2PPtH4k8UJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Start to using Bootstrap with RoR

2013-04-04 Thread Mehmet Vefa
Hey there, I am beginner of RoR. I want to use bootstrap at my project. 
Which point should I start?

-- 
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+unsubscr...@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/msg/rubyonrails-talk/-/e4wJo2Lb4wEJ.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Start to using Bootstrap with RoR

2013-04-04 Thread Greg Akins
http://railsapps.github.com/twitter-bootstrap-rails.html

Greg Akins
http://twitter.com/akinsgre



On Thu, Apr 4, 2013 at 8:11 AM, Mehmet Vefa mehmetv...@gmail.com wrote:

 Hey there, I am beginner of RoR. I want to use bootstrap at my project.
 Which point should I start?

 --
 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+unsubscr...@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/msg/rubyonrails-talk/-/e4wJo2Lb4wEJ.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: Help with error messages

2013-04-04 Thread andreo
can you show us the piece of code you using to handle the success case?

flash is an hash with very useful entries:

inside your controller you should be doing something like:
flash[:error] = object.errors

or something like that if you pass us your controller code it would be 
easier to help you and what is that you doing  on the case of no success.

On Wednesday, 3 April 2013 07:35:30 UTC+2, Konstantinos Georgokitsos wrote:

 Hiall,

 Please bear with me as I am new to rails.

 I have the following problem:

 I have 2 models, Client and Product. Product is dependent, and as such, 
 within the Client show view I created a Product creation form, to create 
 products that belong to a client. After successful or unsuccessful creation 
 I return to the Client show view. There I wanted to show any errors if the 
 creation went wrong, but I can't seem to be able to access the @product I 
 used when trying to create the Product instance, to get to its errors. Do I 
 have to pass that @product when redirecting to client_path(client)? And if 
 so, how?

 BTW, success works, as I use flash to show that, but with the errors I did 
 want to show them in a different position, above the form. If nothing else 
 works, I guess I should pass the errors to flash, but I don't know how to 
 do that either.


-- 
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+unsubscr...@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/msg/rubyonrails-talk/-/dQD41M8-0TQJ.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Help with single page application structure

2013-04-04 Thread Walter Lee Davis

On Apr 4, 2013, at 8:31 AM, tamouse mailing lists wrote:

 
 On Apr 4, 2013 7:20 AM, Johan Vauhkonen johan.vauhko...@gmail.com wrote:
 
  Is it a viable alternative to separate client and back end?
 
  To have AngularJS take care of everything client side and Rails take care 
  of only the back end?
 
 
 Absolutely, you can go so far as to have your SPA initial download be a 
 static index.HTML in ../public, and just have your routes speak JSON to the 
 Angular requests. I'm working on this currently only using backbone and 
 underscore.

There's a few Railscasts that cover Ember and Angular and they all start from 
this premise. You use Rails, but you don't do that much in it. It's just there 
providing the persistence, and all of your real work happens in the public 
folder.

Walter

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Help with single page application structure

2013-04-04 Thread Johan Vauhkonen
I've initially made a HomeController that serves the initial index view 
(with it set as the root in routes) but I think I like the /public way 
better.

Thanks for the idea!


On Thursday, 4 April 2013 14:31:09 UTC+2, tamouse wrote:

Absolutely, you can go so far as to have your SPA initial download be a 
 static index.HTML in ../public, and just have your routes speak JSON to the 
 Angular requests. I'm working on this currently only using backbone and 
 underscore.
  

-- 
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+unsubscr...@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/msg/rubyonrails-talk/-/O2rtjdsyAmQJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: validates uniqueness scope allow_blank/allow_nil - validation error

2013-04-04 Thread Андрей Большов
think it should be:
 validates :game_id, uniqueness: {scope: :genre_id, allow_blank: true}

среда, 3 апреля 2013 г., 13:56:48 UTC+4 пользователь Lephyrius написал:

 I have this in a model: 
 class GenreBadge  ActiveRecord::Base 

   belongs_to :game, counter_cache: :genre_badges_count, touch: true 
   belongs_to :genre 
   validates :game_id, uniqueness: {scope: :genre_id}, allow_blank: 
 true 

 end 

 When I get one existing genre badge 
 genre_badge = game.genre_badges.first 
 genre_badge.game_id = nil 
 genre_badge.save! 

 It creates an validation exception: 
 ActiveRecord::RecordInvalid: Validation failed: Game has already been 
 taken 

 I already have have specified that I want to allow_blank. I really 
 don't know why I get the validation error. I also tested allow_nil but 
 got the same error. 


-- 
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+unsubscr...@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/msg/rubyonrails-talk/-/VGGosWbwnjQJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Confusion over Postgres usernames/passwords/databasenames

2013-04-04 Thread Jason Hsu, Android developer
I have a Ruby script 
(https://github.com/jhsu802701/bsf-scrape/blob/master/scrape.rb) that 
scrapes web pages and stores the results in a Postgres database.  I'm 
trying to set this up not only in the development environment but in a 
production environment as well, and the production environment is giving me 
authentication errors.

I'm confused over the names and passwords.  There are:
1A.  Local machine (user1A and password1A): used for logging in when I boot 
up Linux, owner of the Ruby script
1B.  Local Postgres (user1B and password1B): the username and password for 
PostSQL
1C.  Name of the local Postgres database (db1C)
2A.  Web host SSH (user2A and password 2A): the username and password for 
connecting to the production environment through SSH
2B.  Web host Postgres (user2B and password 2B): the username and password
2C.  Name of the remote Postgres database (db1C)

The script has a class called FundDatabase.

A password needs to be specified in the conn function within the 
FundDatabase class:
def connect
@conn = PG.connect(
:dbname = $db_name,
:user = $db_user,
:password = $db_password)
end

I keep getting confused.  My questions:
1.  When I create a local superuser (user1B) with the command CREATE ROLE 
[local username] SUPERUSER LOGIN;, why don't I need to provide a password 
(password1B) specific to this user?
2.  In order to get my script to run, user1B must be the same as user1A, or 
I get an authentication error.  Am I correct in using the same usernames 
both for my local machine and the local Postgres database?
3.  In the @conn function in my script in the production environment, am I 
supposed to use my SSH login (user2A) and password (password2A)?  Or am I 
supposed to use my database login (user2B) and password (password2B)?  Do 
user2A and user2B need to be one and the same (just like user1A and user1B)?

-- 
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+unsubscr...@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/msg/rubyonrails-talk/-/EttEUZJmDAUJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] heruko performance vs shared hosting performance

2013-04-04 Thread John Merlino
This guy is using godaddy shared hosting for his wordpress blog. I
think it's currently $5 a month. I was thinking to use Rails for his
next project. But I wouldn't want costs to exceed more than $20 per
month. I contacted heroku and they said that 1 dyno is free to host
your ruby on rails app and each additional dyno is $30 a month. A
single Heroku dyno provides 512mb ram and 1024mb swap. It has 4
(virtual) CPU cores (Intel Xeon X5550 @ 2.67GHz). 512mb ram doesn't
seem to be much, particularly for memory-intensive processing.
Although, the multiple CPU cores may enhance multi-threading. That
said, this really isn't going to be a memory hog. Now I was curious to
compare these specs with that of a shared hosting environment (where
many different customers share the same resources). For example,
godaddy says this about their shared hosting Currently there is not a
‘set number’ for CPU resources. Mostly because we have multiple
hardware platforms in the wild. Simply put, if your processes degrade
performance for other customers on the server(s) we will take actions
to protect the other customers. So that's not much of a comparison.
But does anyone have any experience on shared hosting (I know that
most shared hosting environments dont support ruby - but Im sure you
used it for other platfroms like asp.net/php) vs heroku, and if
someone is used to shared hosting with moderate traffic to their site,
would you notice a significant performance downgrade if the site is
moved to heroku on 1 dyno?

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] heruko performance vs shared hosting performance

2013-04-04 Thread John Merlino
This guy is using godaddy shared hosting for his wordpress blog. I
think it's currently $5 a month. I was thinking to use Rails for his
next project. But I wouldn't want costs to exceed more than $20 per
month. I contacted heroku and they said that 1 dyno is free to host
your ruby on rails app and each additional dyno is $30 a month. A
single Heroku dyno provides 512mb ram and 1024mb swap. It has 4
(virtual) CPU cores (Intel Xeon X5550 @ 2.67GHz). 512mb ram doesn't
seem to be much, particularly for memory-intensive processing.
Although, the multiple CPU cores may enhance multi-threading. That
said, this really isn't going to be a memory hog. Now I was curious to
compare these specs with that of a shared hosting environment (where
many different customers share the same resources). For example,
godaddy says this about their shared hosting Currently there is not a
‘set number’ for CPU resources. Mostly because we have multiple
hardware platforms in the wild. Simply put, if your processes degrade
performance for other customers on the server(s) we will take actions
to protect the other customers. So that's not much of a comparison.
But does anyone have any experience on shared hosting (I know that
most shared hosting environments dont support ruby - but Im sure you
used it for other platfroms like asp.net/php) vs heroku, and if
someone is used to shared hosting with moderate traffic to their site,
would you notice a significant performance downgrade if the site is
moved to heroku on 1 dyno?

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] heruko performance vs shared hosting performance

2013-04-04 Thread Matthew Witek
One thing to note on the heroku free service.  They will shutdown your dyno 
after 30 mins of inactivity and the next user to visit the site will have a 
lengthy load time since the dyno has to restart on the next request.  If you do 
decide to go with heroku pay for the extra dyno and you won't have to worry 
about the idling.  
https://devcenter.heroku.com/articles/dynos#dyno-idling

 
On Apr 4, 2013, at 10:38 AM, John Merlino stoici...@aol.com wrote:

 This guy is using godaddy shared hosting for his wordpress blog. I
 think it's currently $5 a month. I was thinking to use Rails for his
 next project. But I wouldn't want costs to exceed more than $20 per
 month. I contacted heroku and they said that 1 dyno is free to host
 your ruby on rails app and each additional dyno is $30 a month. A
 single Heroku dyno provides 512mb ram and 1024mb swap. It has 4
 (virtual) CPU cores (Intel Xeon X5550 @ 2.67GHz). 512mb ram doesn't
 seem to be much, particularly for memory-intensive processing.
 Although, the multiple CPU cores may enhance multi-threading. That
 said, this really isn't going to be a memory hog. Now I was curious to
 compare these specs with that of a shared hosting environment (where
 many different customers share the same resources). For example,
 godaddy says this about their shared hosting Currently there is not a
 ‘set number’ for CPU resources. Mostly because we have multiple
 hardware platforms in the wild. Simply put, if your processes degrade
 performance for other customers on the server(s) we will take actions
 to protect the other customers. So that's not much of a comparison.
 But does anyone have any experience on shared hosting (I know that
 most shared hosting environments dont support ruby - but Im sure you
 used it for other platfroms like asp.net/php) vs heroku, and if
 someone is used to shared hosting with moderate traffic to their site,
 would you notice a significant performance downgrade if the site is
 moved to heroku on 1 dyno?
 
 -- 
 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+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
 
 

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: heruko performance vs shared hosting performance

2013-04-04 Thread Jason Hsu, Android developer
Heroku is prohibitively expensive, and GoDaddy is the Wal-Mart of web hosts.

Why not use WebFaction?  It's much better than GoDaddy and much cheaper 
than Heroku.

-- 
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+unsubscr...@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/msg/rubyonrails-talk/-/kQReLr86wb0J.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] heruko performance vs shared hosting performance

2013-04-04 Thread Hassan Schroeder
On Thu, Apr 4, 2013 at 7:38 AM, John Merlino stoici...@aol.com wrote:

would you notice a significant performance downgrade if the site is
 moved to heroku on 1 dyno?


Given that the heroku entry tier is free and super easy to set up, why
not just deploy an existing app you're familiar with and compare the
performance yourself?

Or develop the new app, deploying to heroku as you go, and see if
the performance of *that specific app* -- which is the only thing that
really counts -- is acceptable. If not, pay to upgrade or move on :-)

-- 
Hassan Schroeder  hassan.schroe...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: help me test how many requests can be available for one server in Ruby On Rails?

2013-04-04 Thread Robert Walker
haxuan lac wrote in post #1103604:
 I am try test how many requests can be available for one server in Ruby
 On Rails but i don't know how to do?
 I read some Page but i want ask some one can explaint more clearly this
 problem.
 If someone had done this problem can give me some advice?Thanks

http://guides.rubyonrails.org/performance_testing.html

-- 
Posted via http://www.ruby-forum.com/.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] rendering instance value to partial views from controller

2013-04-04 Thread Praneeth
hi i have a problem in graphs:
am representing data in graphical view and in that i put from date, end 
date and search button
when i select from date, end date and when i press search, values are going 
into controller through ajax and rendering partial but i can't able to pass 
the instance variable in partial view. i have tried the following
in the controller:
def abc
@x1 = Model1.all
@y1 = Model2.all

render :partial = partial_name, :@x1 = @x1, :@y1 = @y1
render :partial = filter_data, :locals = { :@x1= @x1, :@y1 = @y1 }
end

in the partial view:

div id=line-example style=width: 1000px; height: 350px; margin-top: 
50px; margin-left: 100px;/div
script

window.onload = function () {

Morris.Line({
element: 'line-example',
data: [ % for j in 0...@y1.length %
{y: '%= @y1[j]%', a: '%= @x1[j] %'},

% end %],
xkey: 'y',
ykeys: ['a'],
labels: ['Series A']
});
};
/script

-- 
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+unsubscr...@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/msg/rubyonrails-talk/-/C0GB8xoBGogJ.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Confusion over Postgres usernames/passwords/databasenames

2013-04-04 Thread Craig White

On Apr 4, 2013, at 7:32 AM, Jason Hsu, Android developer wrote:

 I have a Ruby script 
 (https://github.com/jhsu802701/bsf-scrape/blob/master/scrape.rb) that scrapes 
 web pages and stores the results in a Postgres database.  I'm trying to set 
 this up not only in the development environment but in a production 
 environment as well, and the production environment is giving me 
 authentication errors.
 
 I'm confused over the names and passwords.  There are:
 1A.  Local machine (user1A and password1A): used for logging in when I boot 
 up Linux, owner of the Ruby script
 1B.  Local Postgres (user1B and password1B): the username and password for 
 PostSQL
 1C.  Name of the local Postgres database (db1C)
 2A.  Web host SSH (user2A and password 2A): the username and password for 
 connecting to the production environment through SSH
 2B.  Web host Postgres (user2B and password 2B): the username and password
 2C.  Name of the remote Postgres database (db1C)
 
 The script has a class called FundDatabase.
 
 A password needs to be specified in the conn function within the FundDatabase 
 class:
 def connect
 @conn = PG.connect(
 :dbname = $db_name,
 :user = $db_user,
 :password = $db_password)
 end
 
 I keep getting confused.  My questions:
 1.  When I create a local superuser (user1B) with the command CREATE ROLE 
 [local username] SUPERUSER LOGIN;, why don't I need to provide a password 
 (password1B) specific to this user?
 2.  In order to get my script to run, user1B must be the same as user1A, or I 
 get an authentication error.  Am I correct in using the same usernames both 
 for my local machine and the local Postgres database?
 3.  In the @conn function in my script in the production environment, am I 
 supposed to use my SSH login (user2A) and password (password2A)?  Or am I 
 supposed to use my database login (user2B) and password (password2B)?  Do 
 user2A and user2B need to be one and the same (just like user1A and user1B)?

postgresql authentication is accomplished by a file called pg_hba.conf on the 
server itself and you should located that file, make any changes you need to 
make and restart the postgresql server to implement.

One the user can connect, the actual users (or groups) must have assigned 
permissions to read, write to the particular database within postgres itself.

Craig

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] rendering instance value to partial views from controller

2013-04-04 Thread Colin Law
On 4 April 2013 18:18, Praneeth praneetheee...@gmail.com wrote:
 hi i have a problem in graphs:
 am representing data in graphical view and in that i put from date, end date
 and search button
 when i select from date, end date and when i press search, values are going
 into controller through ajax and rendering partial but i can't able to pass
 the instance variable in partial view. i have tried the following
 in the controller:
 def abc
 @x1 = Model1.all
 @y1 = Model2.all

 render :partial = partial_name, :@x1 = @x1, :@y1 = @y1
 render :partial = filter_data, :locals = { :@x1= @x1, :@y1 = @y1 }

render :partial = filter_data, :locals = { :x1=@x1, :y1 = @y1 }
then use x1 and y1 in the partial.  See
http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials

If that still does not work then insert puts statements in the partial
to print the values of things to see what is going on.  The print will
appear in the server window.  Then you will know whether it is getting
the data to the view that is the problem or whether it is the view
code itself.

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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Redirect_to without reload?

2013-04-04 Thread Dave Castellano
Hi,

I am slowly learnng ROR and wondering if anyone  can point me in the
general direction to go with the following problem.

User is filling out a form (question model)  and needs to leave the page
to select an image from a gallery (picture model).  When the user
selects and saves the image they are redirected back to the original
form. How is this done without reloading the question form and losing
the data?  Is there a standard for doing this? I have considered saving
when leaving page and redirecting to edit/update form but cant save data
unless all fields filled out due to validation.

I am having fun learning Rails so even a clue as to direction to take
would be helpful. I'm happy to spend the time figuring out the
details...

Thanks!

-- 
Posted via http://www.ruby-forum.com/.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Redirect_to without reload?

2013-04-04 Thread Scott Ribe
On Apr 4, 2013, at 7:50 PM, Dave Castellano wrote:

 I have considered saving
 when leaving page and redirecting to edit/update form but cant save data
 unless all fields filled out due to validation.

Well, you can put what the user entered in the session, which you should really 
be careful about--you really shouldn't store a lot of data in the session, so 
this is kind of a quick and dirty hack suggestion.

You can have a table for partially-filled forms, which is not subject to 
validation, and save to that during editing, and move data from there to the 
real table on commit.

You can add an in-progress flag to your table, and check that during 
validation.

In both of the latter cases, you need a timestamp and some process to purge 
data that results from abandoned sessions.

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Re: help me test how many requests can be available for one server in Ruby On Rails?

2013-04-04 Thread Jeffrey Jones

On 05/04/13 01:16, Robert Walker wrote:

haxuan lac wrote in post #1103604:

I am try test how many requests can be available for one server in Ruby
On Rails but i don't know how to do?
I read some Page but i want ask some one can explaint more clearly this
problem.
If someone had done this problem can give me some advice?Thanks

http://guides.rubyonrails.org/performance_testing.html

At the bottom of that page there are links to other resources. Using 
JMeter to load-test your
application while using an application monitoring program like New Relic 
to see how your

app responds is a good idea.

--
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] rendering instance value to partial views from controller

2013-04-04 Thread Thota praneeth
i have tried x1 and y1 also still i didn't get the graph it is showing
empty page, but when i render that @x1 or x1 in text_field_tag it is
displaying. How can i pass that variables in javascript


On Fri, Apr 5, 2013 at 1:08 AM, Colin Law clan...@googlemail.com wrote:

 On 4 April 2013 18:18, Praneeth praneetheee...@gmail.com wrote:
  hi i have a problem in graphs:
  am representing data in graphical view and in that i put from date, end
 date
  and search button
  when i select from date, end date and when i press search, values are
 going
  into controller through ajax and rendering partial but i can't able to
 pass
  the instance variable in partial view. i have tried the following
  in the controller:
  def abc
  @x1 = Model1.all
  @y1 = Model2.all
 
  render :partial = partial_name, :@x1 = @x1, :@y1 = @y1
  render :partial = filter_data, :locals = { :@x1= @x1, :@y1 = @y1 }

 render :partial = filter_data, :locals = { :x1=@x1, :y1 = @y1 }
 then use x1 and y1 in the partial.  See
 http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials

 If that still does not work then insert puts statements in the partial
 to print the values of things to see what is going on.  The print will
 appear in the server window.  Then you will know whether it is getting
 the data to the view that is the problem or whether it is the view
 code itself.

 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+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.