Displaying 20 results from an estimated 300000 matches similar to: "Global function"
2006 Aug 10
1
reusing previous code
Hi,
I have a couple of controllers, views, models and mailers for a given
functionality (for example, user registration). ?what is the best way to
share them between multiple applications so that I don''t have to copy them
over and over again?
Thanks.
2006 Jun 10
0
DRY Up Lots o'' Mailers
I have a heap of
fill-out-form/send-website-operator-mail/send-user-confirmation types of
forms. It''s daunting when you think about how many files it takes to do
this. I''m not coming up with an obvious "Rails" way to pull it off, so I
thought it''d be good to know if anyone else has worked through this (7 per
form!).
models/
my_form_data.rb
2006 Jan 03
3
Global functions and variables.
Hey People,
I''m fairly new to Rails and have perhaps an obvious question. I would like
to know if there is a place that I can declare variables and methods that
are globally available to all controllers. My main reason for this is I like
to auto generate select boxes based off of the contents of a hash and would
like to be able to do this in all views in all controllers, so that I do not
2006 May 31
2
Storing a NULL value from a radio_button
Hi, I''ve a boolean database field (tinyint(1)) wich allows nulls.
Then, I''ve something like this:
radio_button(''server'',''customer_has_login'',"NULL")
radio_button(''server'',''customer_has_login'',true)
radio_button(''server'',''customer_has_login'',false)
The problem is
2006 Jul 18
7
Observer not working
Help please.
I''m trying to observe a User class, but I can''t get this to work, the
after_create method never gets called... (the breakpoint never gets
called)
app/models/user_observer.rb:
class UserObserver < ActiveRecord::Observer
def after_create(user)
breakpoint
setting =
2006 Feb 16
0
Shouldn''t mailers be controllers?
Anybody else think that mailers are more like controllers than models?
After all, they even have associated views. And they''re not associated
with any data (like a database table). Furthermore, if they were
controllers, you could use url_for in their templates!
Joe
--
Posted via http://www.ruby-forum.com/.
2006 Aug 02
7
String lenth limit
Hi,
I''ve seen some time ago a function which, given a string like "this is a
very long string" would return , for example limitin it to 10 chars "this
is a..." , but I can''t remember where..... I''ve searched throwth the apis
of rails and ruby itself and I can''t find it.
Thanks everybody..
2005 Oct 12
1
Global helper method?
I want a method to be accessible from everywhere in my app (it''s a Gaussian
RNG) - I''ve already put them as protected methods in application.rb but that
would only allow them to be accessed from controllers.
I have a method in a model that needs access to this too, and I''d prefer not
performing the calculations outside the model. Copying the method definition
into the
2006 Jun 21
2
raw sql and columns order
Hi, I''ve a model with the following method:
def self.run(sql)
return connection.select_all(sql)
end
so, the value returned is an array of hashes... the problen is that the sql
command:
"select name, id from table"
and
select id,name from table"
returns the columns in the same order (name, id).
And in my view, I need to keep the order of the SQL command.
2008 Dec 17
3
Access from common class
Hello!
I have made a common class and put it to the /lib folder of my Rails
application.
Now I have some problems with access to:
1. Mailers
Call to SupportMailer.send_activation_email gives an error:
NoMethodError (undefined method `send_activation_email'' for
SupportMailer:Class):
Ok, I have changed my SupportMailer class - give a prefix to the
function
function send_activation_email
2006 Jan 06
3
Where to place a global function
Hi all,
I have a little function called format_price(price) that simply formats the
argument as a dollar sign, dollar amount, dot and penny amount. Then, in
a .rhtml file, I could do this:
<%= format_price(item.unit_price * item.quantity) %>
But where do I put the format_price() function definition? The app couldn''t
find it in app/controllers/application.rb. Where do I put it
2011 Feb 01
0
Announcing sorcery-0.1.0
Hi,
I''m please to announce, after 4 weeks of development, that I''ve just
released the first version of sorcery gem:
https://github.com/NoamB/sorcery
sorcery is an authentication gem plugin for Rails 3 inspired by
Authlogic, Devise and restful-authentication. You can see how it is used
with an example application here:
https://github.com/NoamB/sorcery-example-app
This gem
2006 Jan 26
1
"Helper" function for my models
I''d like to create a validation function that I can use in all of my
models. What''s the best way to create a method that will be available
to all of my models? It looks like Helper methods only work in Views
and methods in the Application class only work in controllers, so how
do I make one for models?
I hope this question isn''t too lame, it seems like something I
2006 Apr 12
3
acts_as_authenticated trouble
First off, I''d like to address that I''m n00bs.
I''ve read the README and blogs associated with this plugin, and there
really isn''t too much documentation. I have the newest version of
rails,ruby, and acts_as_authenticated installed.
#The setup
I set up the acts_as_authenticated in the following manner.
*created a table called "accounts" in the
2006 Mar 22
3
Rendering partials in ActionMailer?
Hello,
Is anyone out there rendering partials successfully in ActionMailer
templates?
I am having trouble with this, and wasn''t sure if it was my
configuration or something with a version of Rails I''m running.
We''ve got over 15 mailer templates, all working like a charm.
But we have a piece of shared code, that we''d really like to not have to
copy &
2006 Mar 24
0
merging models/views with scaffolding
Allo,
Just started playing around with RoR/scaffolding and have been
impressed so far. However, it seems to create a 1:1 relationship
between Controllers and Models and the basic CRUD actions -- I need to
CRUD two models from the same views and actions.
I have:
Book model
Book controller, with create/edit/show/destroy/list actions and the
scaffold-gen''ed views.
Category model
Category
2006 Feb 17
2
Dealing with *a lot* of Mailers
Anybody here deal with "a lot" of ActionMailers ?
I have a lot of places within my application that send out emails to various
parties.
My /views directory has a directory for each type of mail... ie:
new_user_mailer/
forgot_password_mailer/
...etc
The /views directory is getting quite full of directories because of this,
and I''ve tried working some
magic to get the views
2011 Apr 23
1
rake spec fails where rake spec:(models|controllers|views) pass
I''m still trying to work into Ruby 1.9.2 and am now experiencing
something that makes no sense to me. Using rspec 1.3.2 and rspec-rails
1.3.4 with rails 2.3.11 on ruby 1.9.2-p180, when I
$ rake spec:models
they all pass. When I
$ rake spec:controllers
they all pass. When I
$ rake spec:views
they all pass. But when I
$ rake spec
I get
<path to
2006 May 20
2
Migrate database to a new one using migrations.
Hi,
I''ve an applicattion actually in production wich i wrote in php last
year. Now, I''m working on a new version in Ruby/Rails.
So, can someone tell me how can I generate a migration so that every
time I run it the "data" from the old db get''s copied to the new one??
Note that _I''ve already the schema, I want something that automatically
could
2006 Jun 07
2
script/generate scaffold pluralizes class names
Hi everyone,
I''m a rails & ruby nuby, and this is my first post to the list.
Here''s my environment in case it helps diagnose my problem:
Ruby version
1.8.4 (powerpc-darwin8.6.0)
RubyGems version
0.8.11
Rails version
1.1.2
Active Record version
1.14.2
Action Pack version
1.12.1
Action Web Service version
1.1.2
Action Mailer version
1.2.1
Active Support version
1.3.1
I did