Displaying 20 results from an estimated 500 matches similar to: "How to extend a helper using plugin?"
2010 Mar 18
1
capitalize and utf8 international symbols
Hi there,
Being a relatively happy Rails user I suddenly noticed that
string#capitalize and friends do not play well with international
characters well. Sample console session:
$ ./script/console
Loading development environment (Rails 2.2.3)
>> $KCODE
=> "UTF8"
>> "яблоко".capitalize
=> "яблоко"
Where "Яблоко" was expected (Russian word
2012 Sep 22
4
Class, Module, Object
>> reload!
Reloading...
=> true
>> puts Class < Module
true
=> nil
>> puts Module < Class
false
=> nil
>> puts Module < Object
true
=> nil
>> puts Object < Module
false
=> nil
>> Object.parent
=> Object
The above indicates that the Class object instance inherits from the
Module object instance and the Module object instance
2006 Aug 08
2
Extending rails with plugins
I''ve been looking at bottling some functionality up into a plugin, but I''m
having some problems including it.
The structure I have is:
/app/controllers/admin/base_controller.rb:
class Admin::BaseController > ApplicationController
#snip#
end
/vendor/plugins/myplugin/lib/my_module.rb:
module MyModule
def new_func
"New Function"
end
end
2011 Sep 14
1
Hitting 500 status code on invalid UTF-8 byte sequence in params
Hello Core,
Background: with Redmine-1.2 on Rails-2.3.11 we''re experiencing a "500
Internal Server Error" every time a mail with invalid UTF-8 byte
sequence is hitting the MailHandler (the exception comes from the DB
complaining about invalid string in the INSERT statement.)
Since we do care about internal errors we''ve installed
exception_notification plugin and this
2008 May 21
2
Replacing ActiveRecordStore::Session with a custom model
Has anyone managed to replace ActiveRecordStore::Session with their
own model?
In the source (http://dev.rubyonrails.org/browser/trunk/actionpack/lib/
action_controller/session/active_record_store.rb) it says you can
override the default by setting
CGI::Session::ActiveRecordStore.session_class = MySessionClass
I have tried doing this in a number of ways but I get all kinds of
weird errors, as
2008 Aug 24
2
config.after_initialize and development mode
Hi,
I''m using activemerchant and setting up a class variable using
config.after_initialize. It works great for the first request, but
then the variable is nil.
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
OrderTransaction.gateway =
ActiveMerchant::Billing::PaypalGateway.new(...)
end
I''m assuming this is is due to the model reloading after each
2008 Mar 19
3
ApplicationHelper
When working with views, I use instance methods of ApplicationHelper:
# app/helpers/application_helper.rb:
module ApplicationHelper
def distribute(total, min, cutof, list)
[1,2,3]
end
end
# app/views/planner/_mta_colors.rhtml:
<td>
<%
...
dist = distribute(total_v_px, 4, 0, colors.collect{|color| color[1]})
...
%>
So to test the distribute method in ApplicationHelper, I have
2006 Mar 25
3
Rails Plugins: Why to register your own functionality with send()?
Hi there,
I have seen in the file column plugin (
http://www.kanthak.net/opensource/file_column/) from Sebastian Kanthak or
David''s acts_as_taggable plugin that to register my functionality I need to
do something like this:
ApplicationHelper.send(:include, InPlaceEditAssociations)
I am wondering why not:
(a)
module ApplicationHelper
include InPlaceEditAssociatons
end
or:
(b)
2009 Apr 12
4
Can't get an Array function to be visible inside ApplicationHelper
Folks,
I seem to be missing something basic here.
I am trying to call a function from my application layout that will
return me a hash of the roles for the user currently signed in. Here
is the simplified code I have in ApplicationHelper module
class Array
def to_h
Hash[*enum_with_index.to_a.flatten]
end
end
def get_cur_user_roles
["school_admin",
2006 Feb 12
7
form_remote_upload plugin
form_remote_tag does not support the input type=file. This is due to
javascript security limitations. I created a plugin that modifies
form_remote_tag so that if you pass it the option: :html =>
{:multipart => true}, it will submit via an iframe, allowing you to
upload files. It works nicely with file_column :). Currently, it
only works with RJS templates (no :update option), and I only
2006 Sep 29
2
ApplicationHelper is not a parent of SomeHelper?
i have:
# file application_helper.rb
module ApplicationHelper
def load_components
@right_sidebar = ''some stuffs''
end
end
# file user_public/blog_helper.rb
module UserPublic::BlogHelper
def load_components
ApplicationHelper.load_components
@right_sidebar += ''{blog archive}''
end
end
the problem is, i want to load the
2006 Jul 05
2
Serialized object behaves weird
Hi!
I got a class named EinsatzFilter which I serialized to session. Before
saving to session it works afterwards I keep getting the message:
"undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from
ActiveRecord::Base inherited class.
Code:
class EinsatzFilter
include ApplicationHelper
attr_reader :personen, :monat, :projekte, :kunde
2007 Jul 31
11
helper spec not finding rails core helpers
Hi,
My helper specs were going ok until I added a call to a rails
DateHelper method in one of my helpers
http://api.rubyonrails.com/classes/ActionView/Helpers/
DateHelper.html#M000574
The helper runs fine from my view templates, just dies in the spec test.
I boiled my question down to a simple (not too useful) example. I''m
not sure what I''m missing.
#
2006 Feb 09
4
Login_Engine: trouble configuring
Hi Guys,
I''m having some trouble getting login_engine to work. I''ve followed the
steps in the README file to the letter (I think) with the exception of
the Mailer stuff and cannot get my application to run. Heres what I have;
module ApplicationHelper
include login_engine
end
#####################################
require ''login_engine''
class
2007 Jul 24
4
spec''ing helpers that use controller
Hi all,
I''m in the process of creating rspecs for my helpers. One of the
helpers in app/helpers/application_helper.rb looks like this:
def page_name
@page_name || "Define @page_name in
#{controller.controller_name}::#{controller.action_name}"
end
The rspec is simply:
it "should something" do
page_name
end
2008 Jan 24
3
Help to spec a rails helper method that uses content_for
Hi guys,
I am a Rspec newbie and am having problems creating a spec for a RoR helper
method.
I have in fact already implemented the helper method and am trying to create
retrospective specs. I know its the wrong way to do it but I am still
learning Rspec.
In my view I have a call to a helper method.
<% body_class "users" %>
which sets a CSS class declaration in the content_for
2007 Aug 27
2
issue with edge rails and urls
I just switched our project over to Edge Rails, and I''m running into
this problem with all of my helper methods that call _url methods:
NoMethodError in ''ApplicationHelper home_link should generate a valid
home link when User.current and Profile.current is not set''
You have a nil object when you didn''t expect it!
You might have expected an instance of
2009 Jan 26
2
Cannot extend class in Application Helper
Looking for some help with extending existing classes.
In a view I have <td><%=h bmevent.node %></td>. I need further
processing on the output and added a helper:
module ApplicationHelper
class String
def a
self[ /^[^\0]*/ ]
end
end
end
and <td><%=h bmevent.node.a %></td> results in an undefined method `a''
for #<String:0xb6c8105c>
2011 May 29
4
Model load time
Hi, I''m getting a little confused how Rails handles loading models.
I''m on development mode, using Rails 3.1.0.rc1 on ruby 1.8.7
My application models are:
Curso
Legislacao
Usuario
And I have another model that is loaded from a gem Im trying to build:
Cidade
My gem is actually a simple engine:
require ''active_record''
require
2008 Mar 12
1
Testing helper methods in rspec
This is perhaps a naive question, but what is the recommended manner of
testing a helper method in rspec? I have created a simple string manipulation
function and I want to write some tests for it. It it were a script then I
would just add if __FILE__ == $0 and add the tests below that but I do not
feel that this is the best way to handle a rails helper.
The code (I said it was simple) :