Re: [Rails-core] mb_chars.upcase and Ruby 1.9.2

2010-05-13 Thread NARUSE, Yui
2010/5/9 Norman Clarke : > Interesting, I didn't realize this was going to change in 1.9.2. 1.9.2's feature is already froze and it doesn't have such Unicode utilities. We ruby-core know such needs for Unicode utility and had some discussion about it but we can't agree its spec and implementation

[Rails-core] Re: Trouble developing Rails plugins/gems with generators

2010-05-13 Thread Kristian Mandrup
It turned out I had to include the require statement in an initializer. Putting it in the application.rb didn't work (not found error). I has to due with the load order I'm sure. Thanks for the help :) > > I think you still need to require it in the application.rb file. I might be > wrong as I ha

[Rails-core] Request: Make UrlHelper methods available for controllers

2010-05-13 Thread Kristian Mandrup
I had a need for accessing the methods in ActionView::Helpers::UrlHelper in my controllers to conditionally return link HTML to my views depending on login state etc. I think that the UrlHelper should by default be added to all Controllers and methods such as link_to made available for views using

Re: [Rails-core] feedback on a few ActiveSupport::Multibyte patches

2010-05-13 Thread Rodrigo Rosenfeld Rosas
Em 12-05-2010 13:02, Norman Clarke escreveu: On Tue, May 11, 2010 at 16:51, Rodrigo Rosenfeld Rosas wrote: Norman, I checked out your multibyte branch but it is not working for me. Here is what I did: $ cd ~/src/rails $ git remote add norman http://github.com/norman/rails.git $ git remot

[Rails-core] Re: Request: Make UrlHelper methods available for controllers

2010-05-13 Thread Kristian Mandrup
I'm having problems using url_for in a controller. The original method looks like this, but the @controller variable is unknown in this context. However if I remove it, it goes in an endless loop for the Hash case. Anyone? def url_for(options = {}) options ||= {} url = case o

Re: [Rails-core] feedback on a few ActiveSupport::Multibyte patches

2010-05-13 Thread Norman Clarke
On Thu, May 13, 2010 at 16:41, Rodrigo Rosenfeld Rosas wrote: > Em 12-05-2010 13:02, Norman Clarke escreveu: > But at home, I can run 'ação'.mb_chars.upcase in rails console and it works > too. At work, 'ação'.mb_chars yields 'ao'. Any idea why this is not > consistent in both environments? If y

[Rails-core] What is the deal with Controller additions and helper methods!?

2010-05-13 Thread Kristian Mandrup
I have ben struggling the past two days getting a this tiny piece of functionality to work without any success :( Trying to add a simple helper method to my views in order to ensure links are only displayed if the user has the proper rights to access that functionality. def show_link(object

Re: [Rails-core] What is the deal with Controller additions and helper methods!?

2010-05-13 Thread Michael Koziarski
> But using link_to from within this context, somehow I don't have > access to the controller variable used internally, fx in url_for. That's because the controller itself has its own implementation of url_for, if you attempt to reuse those helpers in the controller it's just not going to work. G

Re: [Rails-core] What is the deal with Controller additions and helper methods!?

2010-05-13 Thread Ryan Bigg
On 14 May 2010 07:22, Michael Koziarski wrote: > But I'd question what you're trying to do here, why are your controllers > generating html without using views? > A "sometimes" use-case is putting a link using link_to in the flash. -- Ryan Bigg / Radar -- You received this message because yo

Re: [Rails-core] What is the deal with Controller additions and helper methods!?

2010-05-13 Thread Yehuda Katz
I'd recommend render_to_string :inline for this case. Yehuda Katz Architect | Engine Yard (ph) 718.877.1325 On Thu, May 13, 2010 at 2:31 PM, Ryan Bigg wrote: > > On 14 May 2010 07:22, Michael Koziarski wrote: > >> But I'd question what you're trying to do here, why are your controllers >> gen

[Rails-core] link_to using smart API

2010-05-13 Thread Kristian Mandrup
Trying to use the "smart" API for link_to def create_link(object, label = nil) label ||= auth_labels[:new] link = link_to(label, [:new, object]) if can?(:create, object) link.sub /new\./, 'new/' end But this generates a link like /projects/new.1 , instead of /projects/ new I would assu

Re: [Rails-core] link_to using smart API

2010-05-13 Thread Ryan Bigg
See the other thread for Yehuda's suggestion. On 14 May 2010 07:44, Kristian Mandrup wrote: > Trying to use the "smart" API for link_to > > def create_link(object, label = nil) > label ||= auth_labels[:new] > link = link_to(label, [:new, object]) if can?(:create, object) > link.sub /new\.

Re: [Rails-core] Re: Request: Make UrlHelper methods available for controllers

2010-05-13 Thread Allen Madsen
Kristian, If I understand what you are trying to do, then its a little backwards. You really shouldn't be generating view stuff in the controller. Instead you can create a class variable like @logged_in and then use that to selectively show certain components in the view. Allen Madsen http://www.

[Rails-core] Re: What is the deal with Controller additions and helper methods!?

2010-05-13 Thread Kristian Mandrup
All I actually wanted to do was to add some helper methods for my views. I kind of "solved" the problem by rethinking my approach, as I could see I had gone down a "blind alley". module ApplicationHelper def self.auth_assist_helpers include AuthAssistant::ViewHelpers end end module AuthAs

[Rails-core] select method on ActiveRecord::Relation brakes enumeration

2010-05-13 Thread Neeraj Singh
class Brake scope :good, where(:quality => 'good') end Brake.all.select &:nil? #=> works fine Brake.good.select &:nil? #=> FAILS Last statement fails because Brake.good.select is returning ActiveRecord::Relation and not an array. I have posted a detailed discussion on ticket #4589 . https://ra

Re: [Rails-core] select method on ActiveRecord::Relation brakes enumeration

2010-05-13 Thread Nicolás Sanguinetti
On Fri, May 14, 2010 at 12:22 AM, Neeraj Singh wrote: > class Brake >  scope :good, where(:quality => 'good') > end > > Brake.all.select &:nil? #=> works fine > Brake.good.select &:nil? #=> FAILS > > Last statement fails because Brake.good.select is returning > ActiveRecord::Relation and not an ar