[Rails] Re: Strategies for streamlining view code

2009-11-19 Thread Andi Schacke
Definitely take a look at Florian Hanke's representer-plugin at http://github.com/floere/representer. It gives you the ability to have 'object oriented' views. You put all the logic (conditionals etc.) inside methods of the view-object. Much much easier to test and it results in extra clean views.

Re: [Rails] Re: Strategies for streamlining view code

2009-11-19 Thread tramuntanal
2009/11/19 pharrington xenogene...@gmail.com For simple cases you could just create a helper like this: def admin_only blk yield if current_user.admin? end % admin_only do % some ISH % end % or a helper like: def show_user_info if (current_user.admin?) do 'User is admin.'

[Rails] Re: How to disable params parsing ?

2009-11-19 Thread Frederick Cheung
On Nov 19, 12:47 am, Thibaut Barrère thibaut.barr...@gmail.com wrote: If you can somehow convince rails that the format it is receiving (perhaps via fiddling with routes?) isn't a format it knows how to parse then it won't parse it. I've been reading about that somewhere but at the end

Re: [Rails] Re: How to disable params parsing ?

2009-11-19 Thread Thibaut Barrère
If you'll never need to parse xml requests anywhere you could set the relevant entry in ActionController::Base.param_parsers to nil thanks for the hint - it the application grows, I'll definitely try that :) cheers, -- Thibaut -- You received this message because you are subscribed to the

[Rails] Action mailer configuration

2009-11-19 Thread madhuri godade
Hello, I want to do the user account activation using restful_authentication for that i have to send a mail to the subscribed user so that i can send a activation url for each user. I am able to create a activation url with activation code but the mails are not sending. I want to know the

[Rails] Re: Threads and net/http: am I missing something?

2009-11-19 Thread jhaagmans
I'm a little further on this. I've started logging the process instead of writing to ActiveRecord. This is my code: def schedule_queries t = Time.now hosts = get_hosts(30) logger.info Starting request for #{hosts.count} domains at #{t} domains.each do |domain| Thread.new do

[Rails] Re: Threads and net/http: am I missing something?

2009-11-19 Thread Frederick Cheung
On Nov 19, 11:00 am, jhaagmans jaap.haagm...@gmail.com wrote: I'm a little further on this. I've started logging the process instead of writing to ActiveRecord. This is my code: As you can see, it does do -some- threading, but it finishes requests only once every 10 seconds or so. What am I

[Rails] Re: Threads and net/http: am I missing something?

2009-11-19 Thread jhaagmans
Hi Fred, Thanks for your response. I hope you can answer three questions about this. - Why is it that pharrington's example did work, even though the hosts he used (I copied them) were never resolved before on my server? I should have had the same problem, right? - I've used net-dns before

Re: [Rails] Re: Threads and net/http: am I missing something?

2009-11-19 Thread Conrad Taylor
On Thu, Nov 19, 2009 at 5:22 AM, jhaagmans jaap.haagm...@gmail.com wrote: Hi Fred, Thanks for your response. I hope you can answer three questions about this. - Why is it that pharrington's example did work, even though the hosts he used (I copied them) were never resolved before on my

[Rails] Re: Threads and net/http: am I missing something?

2009-11-19 Thread jhaagmans
Hi Fred, On 19 nov, 14:59, Frederick Cheung frederick.che...@gmail.com wrote: On Nov 19, 1:22 pm, jhaagmans jaap.haagm...@gmail.com wrote: Hi Fred, Thanks for your response. I hope you can answer three questions about this. - Why is it that pharrington's example did work, even though the

[Rails] render problem in builder template

2009-11-19 Thread Ray
Hello guys, I have a file named _bar.html.erb and located at app/views/foo/ In app/views/some_path/sample.atom.builder, neither form of the followings worked as expected: render :partial = 'foo/bar'= MissingTemplate was raised, strange! render :template = 'foo/_bar' = nil Is it

Re: [Rails] Re: Threads and net/http: am I missing something?

2009-11-19 Thread Conrad Taylor
On Thu, Nov 19, 2009 at 6:34 AM, jhaagmans jaap.haagm...@gmail.com wrote: Hi Fred, On 19 nov, 14:59, Frederick Cheung frederick.che...@gmail.com wrote: On Nov 19, 1:22 pm, jhaagmans jaap.haagm...@gmail.com wrote: Hi Fred, Thanks for your response. I hope you can answer three questions

[Rails] Re: UUID

2009-11-19 Thread Rick
I would like to extend this discussion somewhat as I don't see any guarantee that the id generated by the authlogic method will in fact meet the requirement placed on that generated by uuid. The UUID (Universally Unique IDentifier) has it's primary requirement spelled out in the name. The

[Rails] Re: Threads and net/http: am I missing something?

2009-11-19 Thread jhaagmans
Thank you both. Conrad, do you want me to execute this from within BackgroundRB? I'll be back tonight and test it. -- 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-t...@googlegroups.com. To

Re: [Rails] render problem in builder template

2009-11-19 Thread Darian Shimy
Try this (leading slash): render :partial = '/foo/bar' Darian Shimy -- http://www.darianshimy.com http://twitter.com/dshimy On Thu, Nov 19, 2009 at 4:20 AM, Ray xichens...@gmail.com wrote: Hello guys, I have a file named _bar.html.erb and located at app/views/foo/ In

Re: [Rails] Action mailer configuration

2009-11-19 Thread Darian Shimy
Need a lot more information to help, but if you are running in development mode, check your log files for the body of the email. My guess is you are not configured to send them in dev. Start there. Darian Shimy -- http://www.darianshimy.com http://twitter.com/dshimy On Thu, Nov 19, 2009 at

[Rails] Unexpected ActiveResource post contents

2009-11-19 Thread johnr
On Rails 2.3.4 ... I have a client app that is posting a create to an ActiveResource (actually a HyperActiveResource) in a server app. The ActiveResource class is named ResourceObserver with attributes of resource_name and resource_id. In development and testing environments the parameters of the

[Rails] selected checkbox in Controller!!!!

2009-11-19 Thread simoha
hi, I have the following problem: product.controller.rb class Product Controller def show . end end show.rhtml.rb . . % Product.find (: all). each do | product| % = Check_box product, name,: checked = false,: onchange = # (remote_function (: url = (: controller =

[Rails] Re: How can a rails app get its host name?

2009-11-19 Thread Frederick Cheung
On Nov 19, 7:55 pm, explainer keburg...@gmail.com wrote: I would like my Rails app to supply a callback url to another app.  I currently have a yaml file in the config folder in which I put the host name, but I would like to be able to query that dynamically and do away with the yaml file.  

[Rails] Testing custom validations.

2009-11-19 Thread cnjohnson
I have a large number of models with attributes like backup_started_at, backup_ended_at; essentially paired dates. To ensure that start dates are always on or prior to end dates, I have written a custom validation (config/initializers/validators.rb), and I am wondering how to test it. Ideas? Is

Re: [Rails] Testing custom validations.

2009-11-19 Thread Todd A. Jacobs
On Thu, Nov 19, 2009 at 01:55:37PM -0800, cnjohnson wrote: ensure that start dates are always on or prior to end dates, I have written a custom validation (config/initializers/validators.rb), and I am wondering how to test it. Ideas? Is there a best practice for this sort of thing? Doesn't

[Rails] memcached and fragment caching

2009-11-19 Thread eugenio
i'm reading about memcached, which i never used before. it seems really interesting, but i found discording informations about it (and rails). a) what is a reasonable memory usage for memcached? i read on some sites ~1gb while the default on my ubuntu server is only 64mb. i understand it's

Re: [Rails] memcached and fragment caching

2009-11-19 Thread Philip Hallstrom
a) what is a reasonable memory usage for memcached? i read on some sites ~1gb while the default on my ubuntu server is only 64mb. i understand it's application dependent, but do you think that 128mb should be enough for most sites? It completely depends on your application. I've run sites

[Rails] Re: Terminating a request early with throw or raise

2009-11-19 Thread eugenio
i don't know if i understand what you need, but i usually put various checks on a befor_filter. if conditions are not met you will simply return false and the execution stops. On 19 Nov, 23:39, candlerb b.cand...@pobox.com wrote: Is there a standard way in Rails of terminating a request early

[Rails] Re: memcached and fragment caching

2009-11-19 Thread eugenio
On 19 Nov, 23:41, Philip Hallstrom phi...@pjkh.com wrote: compression?  Not sure what you mean.  Memcached is very fast.  Most   people use it because their db isn't fast enough or to lighten the   load... it is an memcached options. but i'm not so convinced about it e.g.: memcache_options = {

Re: [Rails] memcached and fragment caching

2009-11-19 Thread Marc Byrd
Well, you could use something like CloudCache and not worry about allocation - it's elastic. There's a drop-in implementation for the ActiveSupport::Cache interface: http://github.com/quetzall/cloud_cache/ Of course that's best used if you're on EC2 (or EngineYard on EC2). m On Thu, Nov 19,

[Rails] Re: How can a rails app get its host name?

2009-11-19 Thread icke
request.host -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more

Re: [Rails] Re: Testing custom validations.

2009-11-19 Thread Norm Scherer
cnjohnson wrote: On Nov 19, 4:07pm, "Todd A. Jacobs" tjacobs-sndr- b4f...@codegnome.org wrote: Doesn't your unit testing exercise the validator? I'm not an expert on rails testing, but that's where I'd expect it to checked. Yes, indeed my unit tests all pass when

Re: [Rails] How can a rails app get its host name?

2009-11-19 Thread Norm Scherer
explainer wrote: I would like my Rails app to supply a callback url to another app. I currently have a yaml file in the config folder in which I put the host name, but I would like to be able to query that dynamically and do away with the yaml file. Is there a method call that returns the

[Rails] Admin/pages/1 No action responded to 1

2009-11-19 Thread Brent
I'm building a CMS. It works great, but I wanted to make the controllers use a sub directory /admin/. So all I did was add admin:: in front of each controller. It works. But since I did that, the only way to show a page is by going to: /admin/pages/show/1 NOT admin/pages/1 If I go to

[Rails] Re: render problem in builder template

2009-11-19 Thread Ray
Hi Darian, It turned out that in app/views/some_path/sample.atom.builder, render :partial = 'foo/bar' will looking for a template named foo/ _bar.atom.erb( with file extension .atom), since such template do not exists, the MissingTemplate exception was raised. So the solution should be: create a

Re: [Rails] Re: render problem in builder template

2009-11-19 Thread Darian Shimy
Ray, Good find, I didn't know that. Darian Shimy -- http://www.darianshimy.com http://twitter.com/dshimy On Thu, Nov 19, 2009 at 7:48 PM, Ray xichens...@gmail.com wrote: Hi Darian, It turned out that in app/views/some_path/sample.atom.builder, render :partial = 'foo/bar' will looking for

[Rails] sortable_element helper -- How do I prevent round trip to server?

2009-11-19 Thread Joe
I'm using the sortable_element helper method, and for my app I want to use a javascript snippet update the position field without going to the server and saving the data right away. Other things on the page could be changing and the re-order needs to be a quick, lite action. My the drag-to-sort

[Rails] Re: Edit Multiple Model Objects in Single Form

2009-11-19 Thread raji
Hi Todd, I was able to get the form to render properly. I'm still unclear about how to set the values of the field_for fields and access them in the controller code. When I use the following code, only one form value is getting submitted. % form_tag do % % @people.each do |person| % %

[Rails] Re: Terminating a request early with throw or raise

2009-11-19 Thread Jarkko Laine
On Nov 19, 11:27 pm, candlerb b.cand...@pobox.com wrote: Why do you need to terminate a request early?  Is this an HTTP request? By request I meant controller action. Within a method called by the controller action, I want to render something and then prevent the controller action from