Re: [Rails] retrieve model name from table name rails 3

2012-06-20 Thread Colin Law
On 20 June 2012 07:24, VIKRAM KUMAR MISHRA
 wrote:
> Hi All,
>
>  I want to derive the model name from table name.
>
> One method i got is using table_name.classify. But this does not give actual
> model name. The scenario is
>
> Class User < ActiveRecord::Base
>
>    self.table_name = "abc_xyz"
>
> end
>
> Now i want to retrieve the model name from table name "abc_xyz" which should
> be User.

Sorry for not answering the question, but I cannot contain my
curiosity to know why you need to do this.

Colin

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: How install libv8 (therubyracer) Windows 7

2012-06-20 Thread Alan M.
Hi Everaldo,
I'm also using Windows 7 and I've had the same problem as Felipe, I
tried including
gem 'therubyracer', :platform => :ruby
in my gemfile but I still cannot start the "rails server" to start,
since I get the following error:

[WARNING] Please install gem 'therubyracer' to use Less.
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib/less/java_sc
ript/v8_context.rb:2:in `require': cannot load such file -- v8
(LoadError)
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less/java_script/v8_context.rb:2:in `'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less/java_script.rb:9:in `require'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less/java_script.rb:9:in `default_context_wrapper'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less/java_script.rb:17:in `context_wrapper'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less/loader.rb:10:in `initialize'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less.rb:14:in `new'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less.rb:14:in `'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less.rb:9:in `'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-rails-2.2
.3/lib/less/rails.rb:6:in `require'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-rails-2.2
.3/lib/less/rails.rb:6:in `'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-rails-2.2
.3/lib/less-rails.rb:1:in `require'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-rails-2.2
.3/lib/less-rails.rb:1:in `'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22
/lib/bundler/runtime.rb:68:in `require'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22
/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22
/lib/bundler/runtime.rb:66:in `each'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22
/lib/bundler/runtime.rb:66:in `block in require'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22
/lib/bundler/runtime.rb:55:in `each'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22
/lib/bundler/runtime.rb:55:in `require'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22
/lib/bundler.rb:122:in `require'
from C:/Sites/thousandtools/config/application.rb:7:in `
'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:53:in `require'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:53:in `block in '
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:50:in `tap'
from
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:50:in `'
from script/rails:6:in `require'
from script/rails:6:in `'

Everaldo Gomes wrote in post #1062753:
> Hi Felipe!
>
> Try this, please:
>
> gem 'therubyracer', :platform => :ruby
>
> I found this on Stack Overflow:
>
> http://stackoverflow.com/questions/6356450/therubyracer-gem-on-windows
>
> They said that you don't need to install therubyracer on Windows,
> because the OS already comes with a Javascript Runtime Environment
>
> Best Regards,
> Everaldo
>
> On Thu, May 31, 2012 at 8:23 PM, Felipe Pieretti Umpierre

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: How install libv8 (therubyracer) Windows 7

2012-06-20 Thread Alan M.
Hi Everaldo,
I'm also using Windows 7 and I've had the same problem as Felipe, I 
tried including
gem 'therubyracer', :platform => :ruby
in my gemfile but I still cannot start the "rails server" to start, 
since I get the following error:

[WARNING] Please install gem 'therubyracer' to use Less.
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib/less/java_sc
ript/v8_context.rb:2:in `require': cannot load such file -- v8 
(LoadError)
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less/java_script/v8_context.rb:2:in `'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less/java_script.rb:9:in `require'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less/java_script.rb:9:in `default_context_wrapper'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less/java_script.rb:17:in `context_wrapper'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less/loader.rb:10:in `initialize'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less.rb:14:in `new'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less.rb:14:in `'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.1/lib
/less.rb:9:in `'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-rails-2.2
.3/lib/less/rails.rb:6:in `require'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-rails-2.2
.3/lib/less/rails.rb:6:in `'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-rails-2.2
.3/lib/less-rails.rb:1:in `require'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-rails-2.2
.3/lib/less-rails.rb:1:in `'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22
/lib/bundler/runtime.rb:68:in `require'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22
/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22
/lib/bundler/runtime.rb:66:in `each'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22
/lib/bundler/runtime.rb:66:in `block in require'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22
/lib/bundler/runtime.rb:55:in `each'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22
/lib/bundler/runtime.rb:55:in `require'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22
/lib/bundler.rb:122:in `require'
from C:/Sites/thousandtools/config/application.rb:7:in `
'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:53:in `require'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:53:in `block in '
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:50:in `tap'
from 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:50:in `'
from script/rails:6:in `require'
from script/rails:6:in `'

Everaldo Gomes wrote in post #1062753:
> Hi Felipe!
>
> Try this, please:
>
> gem 'therubyracer', :platform => :ruby
>
> I found this on Stack Overflow:
>
> http://stackoverflow.com/questions/6356450/therubyracer-gem-on-windows
>
> They said that you don't need to install therubyracer on Windows,
> because the OS already comes with a Javascript Runtime Environment
>
> Best Regards,
> Everaldo
>
> On Thu, May 31, 2012 at 8:23 PM, Felipe Pieretti Umpierre

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] How to send audio files using net/http

2012-06-20 Thread Loganathan Sellapa
HI All,

I want to send audio file via http request as an api cal, not via form
using net/http. I dont want to use any other gems. Please let me know how
can be achieved.

regards,
Loganathan
ViewMe 

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Cannot load such file -- script/../config/boot (LoadError)

2012-06-20 Thread Mandeep Kaur
On Wed, Jun 20, 2012 at 3:45 PM, David Angga  wrote:
> from the error message, there's no config/boot.rb file
> this tutorial will show you how to install bundle on rails 2:
> http://gembundler.com/rails23.html
>
> usualy i'm using rvm to manage multiple applications/ruby/rails on one
> system:
> https://rvm.io//

Using above, gives same error. Please help me to solve this problem.

-- 
Mandeep Kaur
http://mandeepsimak.wordpress.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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Scaling challenge

2012-06-20 Thread PierreW
Hi guys,

Our app has been getting traction recently, and we struggle to cope with 
the traffic. I was hoping you guys could point me in the right direction.

For each request, the app does some heavy calculations. They are not done 
in Ruby, we use a compiled, shared lib for this. Our current architecture 
is:

- user request triggers 2 background jobs (via Workling/Starling)
- the first worker does some pre-processing (including polling the DB), 
call the shared lib, and loop. It sends results along the way to the second 
worker.
- the second worker does some post-processing and sends results back to the 
app.

I think the key problem is the call to the shared lib is blocking, so when 
we get lots of calls at once, it seems to me all the workers are stuck on 
this lib and nothing else happens (there are a limited number of workers).

I have a couple of options in mind, but I have no idea which one should 
give better results:

- upgrade to Ruby 1.9.3 (from 1.8.7)
- migrate from DL/Load to FFI (but I don't believe it sorts the blocking 
issue)
- consider another Ruby implementation
- consider a different architecture. For instance I could run this shared 
lib on a separate instance without anything else (just Ruby processes) but 
I am not sure how to do this considering speed will be key.


Thanks!
PJ

-- 
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/-/exNfURbzd9UJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: How to get password from database using devise

2012-06-20 Thread Manish Nautiyal
Tyler wrote in post #1065431:
> On Wednesday, June 20, 2012 8:20:13 AM UTC-7, ixti wrote:
>>
>>
> I understand the use case, but still doesn't make sense to store the
> password in plain text in the database.  It's actually even more
> pointless
> if all the users are admins... then they call all just see each others'
> passwords.  And it gives the illusion of security, when in actuality
> it's
> one params vulnerability away from giving all-encompassing access to any
> hacker that wants it


Dear Tyler

I don't want to store password in plain text in database. I just want to 
send an email to user that your login & password is this. Devise will 
store password in encrypt form in database.

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: How to get password from database using devise

2012-06-20 Thread Tyler


On Wednesday, June 20, 2012 8:20:13 AM UTC-7, ixti wrote:
>
> On Wed, 20 Jun 2012 08:15:02 -0700 (PDT) 
> Tyler wrote: 
>
> > Why do you want the password in "readable" form?  That goes against 
> > the most basic point of even having a password... 
>
> He disallows users to register. So only admin can create a user 
> account, so he wants the system to send a message to the user that his 
> account was created with such and such login and pass. 
>
>
I understand the use case, but still doesn't make sense to store the 
password in plain text in the database.  It's actually even more pointless 
if all the users are admins... then they call all just see each others' 
passwords.  And it gives the illusion of security, when in actuality it's 
one params vulnerability away from giving all-encompassing access to any 
hacker that wants it

 

>
> -- 
> Sincerely yours, 
> Aleksey V. Zapparov A.K.A. ixti 
> FSF Member #7118 
> Mobile Phone: +34 677 990 688 
> Homepage: http://www.ixti.net 
> JID: zappa...@jabber.ru 
>
> *Origin: Happy Hacking! 
>

-- 
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/-/OT5gKXacVsMJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: why use rescue nil?

2012-06-20 Thread Mirri Kim
Just a reminder: it's just specific with the find(). find_by_* will return
nil unless you add a ! (e,g,, find_by_name!()) then it also returns the
exception

On Wed, Jun 20, 2012 at 8:55 AM, John Merlino  wrote:

> ok I thought it would return nil
>
> thanks for response
>
> On Jun 19, 8:33 pm, Fernando Almeida 
> wrote:
> > if the record is not found the find() throws an exception.
> >
> > 2012/6/19 John Merlino 
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > Hey all,
> >
> > > I saw this piece of code:
> >
> > > @user = User.find(params[:user_id]) rescue nil
> >
> > > why rescue with a nil here? If the user is not found, it will be nil
> > > anyway.
> >
> > > --
> > > 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@googlegroups.com
> .
> > > To unsubscribe from this group, send email to
> > > rubyonrails-talk+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/rubyonrails-talk?hl=en.
> >
> > --
> > Fernando Almeidawww.fernandoalmeida.net
>
> --
> 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@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] retrieve model name from table name rails 3

2012-06-20 Thread VIKRAM KUMAR MISHRA
Hi All,

 I want to derive the model name from table name. 

One method i got is using table_name.classify. But this does not give 
actual model name. The scenario is

Class User < ActiveRecord::Base

   self.table_name = "abc_xyz"  

end

Now i want to retrieve the model name from table name "abc_xyz" which 
should be User.

Any help is highly appreciated.

Thanks
Vikram

-- 
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/-/XStXsH9jW8kJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] help with design issue

2012-06-20 Thread Aleksey V Zapparov
On Wed, 20 Jun 2012 07:03:43 -0700 (PDT)
Shalini Sah  wrote:

> I am a newbie in rails. I am creating a rails app where I query an
> existing database consisting of multiple tables. I created a model
> file corresponding to each database in the model folder. Now the
> problem is I want a consolidated view for all the models. My app will
> basically take some inputs from user and generate a summarized view
> based on the  given inputs by querying multiple tables (and thus
> interacting with many models). So shall i create just one controller
> and put the entire logic in it?? or can i transfer some logic to
> helpers? What would be the ideal design in this case?

I think you need a separate model that will aggregate data from others.


-- 
Sincerely yours,
Aleksey V. Zapparov A.K.A. ixti
FSF Member #7118
Mobile Phone: +34 677 990 688
Homepage: http://www.ixti.net
JID: zappa...@jabber.ru

*Origin: Happy Hacking!


signature.asc
Description: PGP signature


Re: [Rails] Re: Equivalent to trim() PHP

2012-06-20 Thread Aleksey V Zapparov
On Wed, 20 Jun 2012 15:54:25 +0200
Felipe Pieretti Umpierre  wrote:

> One question, I have this follow string
> 
> " Hello \n\r How are you ? \n\r I'm fine ."
> 
> The strip gonna clean \n\r too ?

strip removes ONLY leading and trailing whitespaces, see:
http://www.ruby-doc.org/core-1.9.3/String.html#method-i-strip

Basically, PHP's trim() works the same.

If you want to remove whitespaces inside the string, you need to use
`String#gsub` or `String#squeeze` (depending on what you want to
achieve).


-- 
Sincerely yours,
Aleksey V. Zapparov A.K.A. ixti
FSF Member #7118
Mobile Phone: +34 677 990 688
Homepage: http://www.ixti.net
JID: zappa...@jabber.ru

*Origin: Happy Hacking!


signature.asc
Description: PGP signature


Re: [Rails] Re: How to get password from database using devise

2012-06-20 Thread Aleksey V Zapparov
On Wed, 20 Jun 2012 08:15:02 -0700 (PDT)
Tyler  wrote:

> Why do you want the password in "readable" form?  That goes against
> the most basic point of even having a password...

He disallows users to register. So only admin can create a user
account, so he wants the system to send a message to the user that his
account was created with such and such login and pass.



-- 
Sincerely yours,
Aleksey V. Zapparov A.K.A. ixti
FSF Member #7118
Mobile Phone: +34 677 990 688
Homepage: http://www.ixti.net
JID: zappa...@jabber.ru

*Origin: Happy Hacking!


signature.asc
Description: PGP signature


[Rails] Re: Is activeresource broken in rails 3.2.4?

2012-06-20 Thread cyber c.
Found a solution to the problem , the default index methods of the 
controller should be modified to return records according to the params

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] How to get password from database using devise

2012-06-20 Thread Colin Law
On 20 June 2012 14:04, Manish Nautiyal  wrote:
> Hi all
>
> I'm using rails 3.2.1 + devise 2.0.4
>
> My problem is that in my website only : Admin will create new users no
> direct registration for users. Now when Admin create new_user
> confirmation mail will be send to the user email id. The content of the
> mail is
>
>    user_name
>    user_password
>
> But the password come in encrypted format.

How is the initial pwd being setup?  If the admin is providing a
password then put that in the email.

Colin

>
>
> How I'll get password in readable form.
>
> --
> 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 post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: How to get password from database using devise

2012-06-20 Thread Tyler
Why do you want the password in "readable" form?  That goes against the 
most basic point of even having a password...


On Wednesday, June 20, 2012 6:04:30 AM UTC-7, Ruby-Forum.com User wrote:
>
> Hi all 
>
> I'm using rails 3.2.1 + devise 2.0.4 
>
> My problem is that in my website only : Admin will create new users no 
> direct registration for users. Now when Admin create new_user 
> confirmation mail will be send to the user email id. The content of the 
> mail is 
>
> user_name 
> user_password 
>
> But the password come in encrypted format. 
>
>
> How I'll get password in readable form. 
>
> -- 
> 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 view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/5-TSYvDH_fEJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] help with design issue

2012-06-20 Thread Colin Law
On 20 June 2012 15:03, Shalini Sah  wrote:
> Hi,
>
> I am a newbie in rails. I am creating a rails app where I query an existing
> database consisting of multiple tables. I created a model file corresponding
> to each database in the model folder. Now the problem is I want a
> consolidated view for all the models. My app will basically take some inputs
> from user and generate a summarized view based on the  given inputs by
> querying multiple tables (and thus interacting with many models). So shall i
> create just one controller and put the entire logic in it?? or can i
> transfer some logic to helpers? What would be the ideal design in this case?

There should be very little logic in the controller, but logic in the
controller is usually best moved to the models.  Helpers can be used
to remove logic from the view.  Can you give an example of the sort of
logic you are talking about?

Colin

>
> Any help is really appreciated!!
>
> Thanks & Regards,
> Shalini Sah
>
> --
> 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/-/YiqMMBVkOmQJ.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] help with design issue

2012-06-20 Thread Shalini Sah
Hi,

I am a newbie in rails. I am creating a rails app where I query an existing 
database consisting of multiple tables. I created a model file 
corresponding to each database in the model folder. Now the problem is I 
want a consolidated view for all the models. My app will basically take 
some inputs from user and generate a summarized view based on the  given 
inputs by querying multiple tables (and thus interacting with many models). 
So shall i create just one controller and put the entire logic in it?? or 
can i transfer some logic to helpers? What would be the ideal design in 
this case?

Any help is really appreciated!!

Thanks & Regards,
Shalini Sah

-- 
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/-/YiqMMBVkOmQJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Equivalent to trim() PHP

2012-06-20 Thread Walter Lee Davis
No, it only acts on the outer bounds of the string. Have a look at the 
documentation on ruby-doc.org: 
http://ruby-doc.org/core-1.9.3/String.html#method-i-strip

Walter

On Jun 20, 2012, at 9:54 AM, Felipe Pieretti Umpierre wrote:

> One question, I have this follow string
> 
> " Hello \n\r How are you ? \n\r I'm fine ."
> 
> The strip gonna clean \n\r too ?
> 
> 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 post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
> 

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Equivalent to trim() PHP

2012-06-20 Thread Felipe Pieretti Umpierre
One question, I have this follow string

" Hello \n\r How are you ? \n\r I'm fine ."

The strip gonna clean \n\r too ?

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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] How to get password from database using devise

2012-06-20 Thread Walter Lee Davis

On Jun 20, 2012, at 9:04 AM, Manish Nautiyal wrote:

> Hi all
> 
> I'm using rails 3.2.1 + devise 2.0.4
> 
> My problem is that in my website only : Admin will create new users no
> direct registration for users.

The way that I handle this in my applications is to use Devise Invitable, and 
then restrict the invitation privilege to admins. You don't get to know the 
password, because the user sets it herself when she accepts the invitation. But 
everything else just works. Since you aren't using registerable, you will need 
to provide your own "Update my Profile" method in a controller if you want to 
allow the user to update his profile, but that's covered in the Wiki.

Walter

> Now when Admin create new_user
> confirmation mail will be send to the user email id. The content of the
> mail is
> 
>user_name
>user_password
> 
> But the password come in encrypted format.
> 
> 
> How I'll get password in readable form.
> 
> -- 
> 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 post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
> 

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] How to get password from database using devise

2012-06-20 Thread Manish Nautiyal
Hi all

I'm using rails 3.2.1 + devise 2.0.4

My problem is that in my website only : Admin will create new users no
direct registration for users. Now when Admin create new_user
confirmation mail will be send to the user email id. The content of the
mail is

user_name
user_password

But the password come in encrypted format.


How I'll get password in readable form.

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Strange regression in 3.0.14

2012-06-20 Thread Walter Lee Davis
Yayayayayayaa!

Thanks for the find!

Walter

On Jun 20, 2012, at 8:15 AM, ook ook wrote:

> Found the cause:
> 
> https://github.com/rails/rails/commit/a5a0338b9b3f2f24efde0ae6a56e99b938eff7cf
> 
> And its resolution: Rails 3.0.15 was discreetly released some days ago.
> 
> -- 
> 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 post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
> 

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Strange regression in 3.0.14

2012-06-20 Thread ook ook
Found the cause:

https://github.com/rails/rails/commit/a5a0338b9b3f2f24efde0ae6a56e99b938eff7cf

And its resolution: Rails 3.0.15 was discreetly released some days ago.

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Strange regression in 3.0.14

2012-06-20 Thread Walter Lee Davis
No, nothing yet. I am trying a new server as soon as I have time to migrate, 
but for now I am living dangerously!

Walter

On Jun 20, 2012, at 5:42 AM, ook ook wrote:

> I met strictly the same problem. Have you a solution?
> 
> -- 
> 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 post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
> 

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: why use rescue nil?

2012-06-20 Thread Matt Jones


On Tuesday, 19 June 2012 20:29:25 UTC-4, John Merlino wrote:
>
> Hey all, 
>
> I saw this piece of code: 
>
> @user = User.find(params[:user_id]) rescue nil 
>
> why rescue with a nil here? 


Because the author forgot about find_by_id, which would accomplish the 
exact same thing (returning nil if no record was found).

--Matt Jones 

-- 
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/-/8gD2kFdxxOcJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Extracting SQL statements from the rails development log

2012-06-20 Thread Matt Jones


On Tuesday, 19 June 2012 15:46:12 UTC-4, Gurdipe Dosanjh wrote:
>
> Hi 
>
> I need to extract all the sql statements from the the rails development 
> log.
>
> Is there a quick way to do this using a regular expression or another 
> method?
>
>
If you're looking to grab all the queries, check out the Notification 
system:

http://asciicasts.com/episodes/249-notifications-in-rails-3

the 'sql.active_record' notification will be fired every time there's a 
query.

--Matt Jones 

-- 
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/-/iAb7Rc5h9h4J.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Is activeresource broken in rails 3.2.4?

2012-06-20 Thread Matt Jones


On Monday, 18 June 2012 17:45:45 UTC-4, Ruby-Forum.com User wrote:
>
> Hi, 
>
> I see that 
> Person.find(:all) and Person.find(:all, :params => {id => '2'}) returns 
> all records irrespective of conditions. Is activeresource broken? 
> PS: Im using rails 3.2.4 
>
>
Better question: is the service on the other end paying any attention to 
the parameters? Not going to have much success if it isn't...

--Matt Jones 

-- 
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/-/HulCR5paFrUJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: RSpec test model and mailer

2012-06-20 Thread Danko Danko
Ok, thank you

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: strange assertion result in functional test

2012-06-20 Thread Erwin
[SOLVED]  assigns(:blog)  is OK because @blog is created in the test
setup, and the get :settings  was DENIED ... so the action was never
completed
added the necessary checking in my test :


sign_in  @admin_west
ability = BackofficeAbility.new(@admin_west)
assert ability.can? :settings, Blog
get :settings, :id => @blog[:id]

and now it passes through



On 20 juin, 12:26, Erwin  wrote:
> I am testing the 'settings' action, in my Blog controller
>
>   def settings
>     @blog = Blog.find(params[:id])
>     @setting_form = "settings"
>   end
>
> I wrote the following assertions :
>
>     get :settings, :id => @blog[:id]
>     assert_not_nil assigns(:blog)
>     assert_equal "settings", assigns(:setting_form)
>
> but I get a failure on the assigns(:setting_form) assertion, with diff
> nil ... strange ??  what's up ? any clue ?
> <> expected but was
> <>
> diff:
>   nil
>
> thanks for our feedback

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] strange assertion result in functional test

2012-06-20 Thread Erwin
I am testing the 'settings' action, in my Blog controller

  def settings
@blog = Blog.find(params[:id])
@setting_form = "settings"
  end

I wrote the following assertions :

get :settings, :id => @blog[:id]
assert_not_nil assigns(:blog)
assert_equal "settings", assigns(:setting_form)

but I get a failure on the assigns(:setting_form) assertion, with diff
nil ... strange ??  what's up ? any clue ?
<> expected but was
<>
diff:
  nil

thanks for our feedback

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] The most efficient way to create gem/engine/plugin

2012-06-20 Thread David Angga
use enginex: https://github.com/josevalim/enginex
to create a gem for rails applications

or you could try rubygem and bundler that has a built in feature to
generate you own gem

On Wed, Jun 20, 2012 at 2:51 AM, Colin Law  wrote:

> On 19 June 2012 11:02, debadatta  wrote:
> > Hi all,
> >
> >
> > We are looking for the most efficient way to create
> gem/engine/plugin.Which
> > can be integrated with any application with minimum effort.
>
> Possibly the most efficient way to create it would be to start by
> using google with appropriate keywords to find documentation and
> tutorials on creating gems, engines and plugins.
>
> Colin
>
> >
> >
> > Any suggestion is highly appreceated.
> >
> > --
> > 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/-/3kKy_P0HOHUJ.
> > To post to this group, send email to rubyonrails-talk@googlegroups.com.
> > To unsubscribe from this group, send email to
> > rubyonrails-talk+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/rubyonrails-talk?hl=en.
>
> --
> 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@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>


-- 
*David Angga Prasetya*
*RoR Developers*

skype: david.angga
phone: +62 85 222 1  2
*

*

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: i18n Override Defaults

2012-06-20 Thread Erwin
have a look at  :

https://github.com/middleman/middleman-guides/blob/master/source/extensions/localization.html.markdown

see default_path

On 20 juin, 11:14, Muruga  wrote:
> Hi all,
>          I need an solution to override the template lookup.i.e.,In
> 18n,Rails default is filename.locale.format(aboutus.de.erb).
>
>          What i was looking is locale.filename.format(de.aboutus.erb).
>
>           How to override the default behaviour of Rails i18n .
>
> Thanks in advance...

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Cannot load such file -- script/../config/boot (LoadError)

2012-06-20 Thread David Angga
from the error message, there's no config/boot.rb file
this tutorial will show you how to install bundle on rails 2:
http://gembundler.com/rails23.html

usualy i'm using rvm to manage multiple applications/ruby/rails on one
system:
https://rvm.io//


On Tue, Jun 19, 2012 at 9:45 PM, Mandeep Kaur  wrote:

> Hello Friends,
>
> I want to use multiple Rails versions on my system for different
> applications. For this I have created Gemfile and place that file in
> application folder. Then I have use bundle install command in
> application directory. Its run without giving any error. But when I
> run bundle exec script/server, it gives error (LoadError).
>
> Gemfile includes :
>
> source 'https://rubygems.org'
>
> gem 'rails', '~> 2.3.8'
>
> Then I run, $ bundle install in terminal. After that start the application
> using
>
> $ bundle exec script/server
>
> It gives following error:
>
> $ bundle exec script/server
> script/server:2:in `require': cannot load such file --
> script/../config/boot (LoadError)
>from script/server:2:in `'
>
> Please help me to solve this problem.
>
>
>
> --
> Mandeep Kaur
> http://mandeepsimak.wordpress.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@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>


-- 
*David Angga Prasetya*
*RoR Developers*

skype: david.angga
phone: +62 85 222 1  2
*

*

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Associations join

2012-06-20 Thread Timen E.
Colin Law wrote in post #1065311:
> On 20 June 2012 09:32, Timen E.  wrote:
>> card from my cardlevel array, but i can't seem to access it like this. I
>> can however loop it in a seperate each, but i don't want that obviously.
>
> You have not explained well what you are trying to do, but possibly
> you want to loop through the cardlevels instead of the cards, then for
> each cardlevel you can obtain the card aswell as the other data, so
> something like
>
> <% @user.cardlevels.each do |cl| %>
> <%= cl.card.name %>
> <%= cl.other_data %>
> <% end %>
>
> You might need to check for cl.card nil though.
>
> Colin

You're my savior, thanks alot! It's more the train of thought that needs 
correcting than my code i guess.

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] RSpec test model and mailer

2012-06-20 Thread David Angga
it "should sent an email confirmation" do
  @user  = User.first
  ActionMailer::Base.delivery_method = :test
  ActionMailer::Base.perform_deliveries = true
  ActionMailer::Base.deliveries.clear

  @user.create_reset_code

  @email_confirmation = ActionMailer::Base.deliveries.first
  @email_confirmation.from.should == "..."
  @email_confirmation.to.should == @user.email
  @email_confirmation.body.should .
end

On Wed, Jun 20, 2012 at 4:16 PM, Danko Danko  wrote:

> I have method in model
>
> (User Model)
>
>  def create_reset_code
>  self.attributes = {:reset_code => Digest::SHA1.hexdigest(
> Time.now.to_s.split(//).sort_by {rand}.join )}
>  save(:validate=>false)
>  UserMailer.reset_password_email(self).deliver
>  end
> How can I test it in RSpec? I want to test the code generation, and send
> e-mail
>
> PS : using Google, but found no examples of
>
> --
> 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 post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>


-- 
*David Angga Prasetya*
*RoR Developers*

skype: david.angga
phone: +62 85 222 1  2
*

*

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Associations join

2012-06-20 Thread Colin Law
On 20 June 2012 09:32, Timen E.  wrote:
> Still got one(Hopefuly last for now) question, guys.
>
> I've got the above data now and i can access my cards through users that
> are joined by the cardlevel. I'm trying to loop through all the cards a
> user has as such:
> <% @user.cards.each do |c| %>
>  <%= c.name %>
> <% end %>
>
> And this works great. However i'd like to get some extra info about this
> card from my cardlevel array, but i can't seem to access it like this. I
> can however loop it in a seperate each, but i don't want that obviously.

You have not explained well what you are trying to do, but possibly
you want to loop through the cardlevels instead of the cards, then for
each cardlevel you can obtain the card aswell as the other data, so
something like

<% @user.cardlevels.each do |cl| %>
<%= cl.card.name %>
<%= cl.other_data %>
<% end %>

You might need to check for cl.card nil though.

Colin

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Strange regression in 3.0.14

2012-06-20 Thread ook ook
I met strictly the same problem. Have you a solution?

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: why use rescue nil?

2012-06-20 Thread Alex Mercer
Alson you could just use where:
  @user = User.where(:id => params[:user_id]).first

On Wednesday, June 20, 2012 3:29:25 AM UTC+3, John Merlino wrote:
>
> Hey all, 
>
> I saw this piece of code: 
>
> @user = User.find(params[:user_id]) rescue nil 
>
> why rescue with a nil here? If the user is not found, it will be nil 
> anyway.

-- 
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/-/QRvpn4dYbzcJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] RSpec test model and mailer

2012-06-20 Thread Danko Danko
I have method in model

(User Model)

  def create_reset_code
  self.attributes = {:reset_code => Digest::SHA1.hexdigest(
Time.now.to_s.split(//).sort_by {rand}.join )}
  save(:validate=>false)
  UserMailer.reset_password_email(self).deliver
  end
How can I test it in RSpec? I want to test the code generation, and send
e-mail

PS : using Google, but found no examples of

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] i18n Override Defaults

2012-06-20 Thread Muruga
Hi all,
 I need an solution to override the template lookup.i.e.,In 
18n,Rails default is filename.locale.format(aboutus.de.erb).

 What i was looking is locale.filename.format(de.aboutus.erb).

  How to override the default behaviour of Rails i18n .

Thanks in advance...

-- 
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/-/7OOyi3SWxyUJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Associations join

2012-06-20 Thread Timen E.
Still got one(Hopefuly last for now) question, guys.

I've got the above data now and i can access my cards through users that 
are joined by the cardlevel. I'm trying to loop through all the cards a 
user has as such:
<% @user.cards.each do |c| %>
  <%= c.name %>
<% end %>

And this works great. However i'd like to get some extra info about this 
card from my cardlevel array, but i can't seem to access it like this. I 
can however loop it in a seperate each, but i don't want that obviously.

Any ideas?

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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Thinking Sphinx Problem

2012-06-20 Thread Karthikeyan A.K
We got it! Thanks. We Installed Sphinx from Ubuntu repository thatn from
downloading it from the Sphinx page.

On Tue, Jun 19, 2012 at 6:51 PM, Ewelina Lis wrote:

>  It's hard to tell. It looks like you don't have anything defined in
> define_index.
>
> If you have
>
> define_index do
> indexes name
> *end*
>
> in your model and it doesn't work
> try to tests
>
> indexes "''", :as => :empty
>
> and try then.
>
> Did you look on
> http://freelancing-god.github.com/ts/en/indexing.html#processing ?
> I found everything there. They have good documentation
>
>
>  On Tuesday, 19 June 2012 at 15:07, Karthikeyan A.K wrote:
>
> Hi,
>
> I am using *Thinking Sphinx version 2.0.11 *in one of my project. To
> create an index I ran* **rake thinking_sphinx:index *and I got the
> following error
>
> Generating Configuration to /home/saidev/Ubuntu
> One/burgundy/ssearch/config/development.sphinx.conf
> rake aborted!
> At least one field is necessary for an index
>
> Tasks: TOP => thinking_sphinx:index
> (See full trace by running task with --trace)*
>
> *This is the first time I am using Sphinx on Rails. Any help?*
>
>
>
>
> *
>
> --
> 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/-/cosIlhwbbf4J.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
>  --
> 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@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>



-- 
Nothing is constant

Regards

A.K.Karthikeyan

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Associations join

2012-06-20 Thread Timen E.
Michael Pavling wrote in post #1065301:
> On 20 June 2012 08:51, Timen E.  wrote:
>>
>> undefined method `user' for #
>> Extracted source (around line #3):
>
> @card is a collection of cards (that's how you populate it in the
> "show" action. If it needs to be a single card, you need to find it by
> ID (or some other attribute), if it's supposed to be a collection of
> every card, you need to iterate it in the view and print the user for
> each card.



aaah i see, nonetheless i noticed that i turned it around. I need to get 
the user with it's cards, haha!

What you mentioned did work but it doesn't seem to 'associate' the right 
way around because i'm getting the error SQLite3::SQLException: no such 
column: cards.user_id: SELECT "cards".* FROM "cards"  WHERE 
"cards"."user_id" = 1"".
Shouldn't he query through cardlevels instead of cards?

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Associations join

2012-06-20 Thread Colin Law
On 20 June 2012 08:51, Timen E.  wrote:
> I've just got a really basic setup to see if i got it working:
>
>
> card.rb
> class Card < ActiveRecord::Base
>    attr_accessible :attack, :defense, :name
>    has_many :cardlevels
>  has_many :users, :through => :cardlevels
> end
>
> cardlevel.rb
> class Cardlevel < ActiveRecord::Base
>  attr_accessible :card_id, :level, :user_id
>    belongs_to :user
>  belongs_to :card
> end
>
> user.rb
> class User < ActiveRecord::Base
>    attr_accessible :name
>    has_many :cardlevels
>  has_many :cards
> end
> -
>
> card_controller.rb
> class CardController < ApplicationController
>  def show
>    @card = Card.all

You would have been better to put @cards = Card.all as the result will
be be an (effectively) an array of cards not a single one.

>  end
> end
>
> User & cardlevel are empty for now
> -
>
> Card#show
> Find me in app/views/card/show.html.erb
> <%= @card.user %>
> Where i tried eaching the @card, tried @card.users, @card.user.name etc.
> etc.
> -
>
> The error:
> Showing c:/tuts/kaartje/app/views/card/show.html.erb where line #3
> raised:
>
> undefined method `user' for #

The clue is in the error message, as is often the case, it says that
@card is an Array and the Arrray class does not have a method user.
You can only call user on an individual card.

Colin

> Extracted source (around line #3):
>
> 1: Card#show
> 2: Find me in app/views/card/show.html.erb
> 3: <%= @card.user %>
> Rails.root: c:/tuts/kaartje
>
> Application Trace | Framework Trace | Full Trace
> app/views/card/show.html.erb:3:in
> `_app_views_card_show_html_erb___1042037435_30519240'
> Request
>
> Parameters:
>
> {"id"=>"show"}
> -
>
> --
> 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 post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Associations join

2012-06-20 Thread Michael Pavling
On 20 June 2012 08:51, Timen E.  wrote:
> #card_controller.rb
> class CardController < ApplicationController
>  def show
>    @card = Card.all
>  end
> end
>
> Card#show
> Find me in app/views/card/show.html.erb
> <%= @card.user %>
>
> undefined method `user' for #
> Extracted source (around line #3):

@card is a collection of cards (that's how you populate it in the
"show" action. If it needs to be a single card, you need to find it by
ID (or some other attribute), if it's supposed to be a collection of
every card, you need to iterate it in the view and print the user for
each card.

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Associations join

2012-06-20 Thread Timen E.
I've just got a really basic setup to see if i got it working:


card.rb
class Card < ActiveRecord::Base
attr_accessible :attack, :defense, :name
has_many :cardlevels
  has_many :users, :through => :cardlevels
end

cardlevel.rb
class Cardlevel < ActiveRecord::Base
  attr_accessible :card_id, :level, :user_id
belongs_to :user
  belongs_to :card
end

user.rb
class User < ActiveRecord::Base
attr_accessible :name
has_many :cardlevels
  has_many :cards
end
-

card_controller.rb
class CardController < ApplicationController
  def show
@card = Card.all
  end
end

User & cardlevel are empty for now
-

Card#show
Find me in app/views/card/show.html.erb
<%= @card.user %>
Where i tried eaching the @card, tried @card.users, @card.user.name etc. 
etc.
-

The error:
Showing c:/tuts/kaartje/app/views/card/show.html.erb where line #3 
raised:

undefined method `user' for #
Extracted source (around line #3):

1: Card#show
2: Find me in app/views/card/show.html.erb
3: <%= @card.user %>
Rails.root: c:/tuts/kaartje

Application Trace | Framework Trace | Full Trace
app/views/card/show.html.erb:3:in 
`_app_views_card_show_html_erb___1042037435_30519240'
Request

Parameters:

{"id"=>"show"}
-

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: why use rescue nil?

2012-06-20 Thread Michael Pavling
On 20 June 2012 01:55, John Merlino  wrote:
> ok I thought it would return nil

It would take 30seconds to try it out in a console...

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Re: Associations join

2012-06-20 Thread Colin Law
On 20 June 2012 08:39, Timen E.  wrote:
> Colin Law wrote in post #1065209:
>> On 19 June 2012 13:38, Timen E.  wrote:
>>>
>>> class Cardlevel < ActiveRecord::Base
>>>  belongs_to :users
>>> belongs_to :cards
>>
>> Those should both be singular (:user and :card).  Each cardlevel
>> belongs to one user and card so they should be singular.
>>
>> Colin
>
> That sounds fair indeed, however when i tried i still got the same
> error. This associations got me so bloody confused :')

Post the code for the models, the code that generates the error (with
a few lines each side) and the full error message.

Colin

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Associations join

2012-06-20 Thread Timen E.
Colin Law wrote in post #1065209:
> On 19 June 2012 13:38, Timen E.  wrote:
>>
>> class Cardlevel < ActiveRecord::Base
>>  belongs_to :users
>> belongs_to :cards
>
> Those should both be singular (:user and :card).  Each cardlevel
> belongs to one user and card so they should be singular.
>
> Colin

That sounds fair indeed, however when i tried i still got the same 
error. This associations got me so bloody confused :')

-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Daily Diary

2012-06-20 Thread Colin Law
On 20 June 2012 06:52, Mandeep Kaur  wrote:
> On Wed, Jun 20, 2012 at 1:31 AM, Colin Law  wrote:
>> On 19 June 2012 17:21, Mandeep Kaur  wrote:
>>> I want to create daily diary format and want to print date for whole
>>> year like 1-1-2012 to 1-12-1012 using Ruby on Rails. Is it possible ?
>>> If yes then please guide me.
>>
>> Which part of the problem are you having difficulty with?  It is not
>> clear from your question.
>
> I want to create format as shown in image. After creating that format
> I want to convert it into pdf for taking printouts.
>
> I am not getting how to use the functions for creating that dates and
> line. Please help me to do that.

Do you know the html that you want to generate?  If not then this is
not a Rails question but an html question, in which case the best
thing to do would be to work through some html tutorials.

Colin

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.