You can add it to the test_helper.rb file and it will be included in
all your default tests. Alternatively you could simply put it in a
module (in a separate file in RAILS_ROOT/test and then "include" it in
test_helper.rb or the individual test classes as you need.
On Oct 11, 10:35 am, Marnen Lai
You can use that technique to do something like this in your helper:
link_to("Link!", { :action => "blah", :controller =>
controller.controller_name })
You don't have to use named routes all the time. There are definitely
times where the path hash is advantageous.
On Jun 15, 9:05 pm, bill walto
Very strange. Have you checked postfix at all? I use ExceptionNotifier
in 2.3 with no problems at all.
On Apr 30, 1:25 pm, fausto wrote:
> Hi, i've just installed exception notifier, set in the enviroment.rb
> (i've tried also in an inizializer file and in production.rb in the
> enviroments fold
One issue with splitting the application into 3 will be consistency of
deployment. If the models in the engine change you need to at a
minimum run all the tests in all 3 systems, and possibly make updates,
then find the time to deploy all 3. I know these situations are
solvable, but I don't think
You can use some inheritance and before_filters to handle this.
class ApplicationController < ActionController::Base
def load_panel_data
@data = Data.all
end
end
class OtherController < ActionController::Base
before_filter :load_panel_data
... your normal actions ...
end
In your controller you can redirect to the same action without the
'page' in the querystring if it is equal to 1.
def index
redirect_to :action => 'index' if params[:page] && params
[:page].to_i == 1
params[:page] ||= 1
# your normal code here
end
On Mar 29, 5:03 am, Aldo Italo
wrot
You could always use inheritance.
class Book < ActiveRecord::Base
def destroy
return super if page.empty?
return false
end
end
On Mar 29, 11:10 am, Neal L wrote:
> This is a total noob question, but how do you prevent a record from
> being destroyed if it has any related records. I
try changing the delete link to ad_path(ad) instead of ads_path(ad).
On Mar 24, 10:30 pm, elle wrote:
> Hello,
>
> I am sure this is a simple problem but for some reason I can't get it
> to work.
> I am trying to delete a record. My routes.rb has:
> map.resources :ads
>
> ...the AdsController ha
# routes.rb
map.connect "/projects/:project_slug/:image_slug", :controller =>
"images", :action => "show"
# images_controller.rb
def show
@project = Project.find_by_slug(params[:project_slug])
@image = Image.find_by_slug(params[:image_slug])
...
end
On Mar 8, 8:45 pm, David Lelong
wrote:
to answer your first question, hiding the comments by default is easy.
simply add a "display:none" to the CSS for the divs you wish to be
hidden initially.
On Mar 8, 12:59 am, vishy wrote:
> I have been working on developing a blog site using rails. This is my
> first rails application, hence I
ticket_path is expecting you to pass the ID of the ticket you are
looking for. Something like this:
ticket_path(123)
Run 'rake routes' to get a good idea of what each named route is
doing.
What you need is something like this:
# tickets_controller
def search
show
end
# routes.rb
map.resource
Just make a users table, and create a polymorphic relationship between
users and students or teachers. Then, when the user logs in, check if
they have a student or teacher record associated with them and
redirect properly.
On Mar 3, 1:59 pm, Tony Tony wrote:
> Hi all,
>
> I'm working on trying t
I'm not sure I'm 100% clear, but it sounds like you are saying that a
Repair may only have one combination of Part/Product, and it just so
happens that this combination implies a Level. To me the validation
would be:
class Repair < ActiveRecord::Base
belongs_to :level
belongs_to :product
be
Try something like this:
def current_li(content, x)
klass = x ? "current" : nil
content_tag(:li, content, :class => klass)
end
On Feb 20, 3:55 pm, James Bond
wrote:
> How make a helper:
>
> If value X is true: print else
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~
no standard exists as far as i know. you have 2 options as i see it.
1.) run each link through a redirect. something like:
blah
2.) or use some javascript and implement an onclick handler on the
link to fire an ajax request back to your application
at work i had to implement something similar,
Try this and see what is printed:
if @event.save
puts "Event saved"
else
puts @event.errors.full_messages.inspect
end
What you're doing sounds right, most likely though you have a
validation that is keeping the model from saving.
On Jan 25, 4:44 pm, Sharon Machlis wrote:
> Once a month
it depends on the specific callback in question. the list of available
callbacks can be found here:
http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html
On Jan 24, 11:43 pm, Greg Hauptmann
wrote:
> Hi,
> Re Rails observers,
> (i.e.http://api.rubyonrails.org/classes/ActiveRecord/Obser
"xxx | yyy | zzz | ddd".split(" | ") # => ["xxx", "yyy", "zzz", "ddd"]
On Jan 23, 4:29 pm, Philip Hallstrom wrote:
> > I have string: "xxx | yyy | zzz | ddd"
>
> > I need to split it to: "xxx", "yyy", "zzz" and "ddd",
> > make link to every word like: xxx
>
> > So result must by:
>
> > from this
Check out the docs for ActionController::Base#view_paths. You can
probably monkey with that to get both controllers to look in the same
directory.
On Jan 20, 4:25 pm, "Brian Hogan" wrote:
> Sure. No, there really isn't. It's a convenience thing. Not having to
> specify the template is a blessin
It would also be appropriate to place the ssh.rb file in the lib/
directory. Placing it in app/models/ is fine. It's just a matter of
preference.
On Jan 5, 10:10 pm, Valentino Lun
wrote:
> Dear all
>
> In the MVC architecture framework, the Model is actually communicate
> with database. In my ra
What Mike is hinting at is the way ActiveRecord abstracts database
differences. MySQL and SQLite3 probably use different column types but
this will appear transparent to the developer as ActiveRecord handles
serializing and de-serializing the column data into Ruby objects.
I am not a DBA, and I'm
if the plugin is already installed in vendor/plugins there is no
reason to install it with script/plugin.
On Jan 4, 6:48 pm, Jason Newport
wrote:
> I am trying to install acts_as_list in a rails 2.2.2 project but when I
> try the following: ruby script/plugin install acts_as_list
>
> I get: Pl
The collection and other options are just a hash being passed as
parameters to the resources method. The ruby language defines all
parameters before blocks in method calls. Try the following:
map.resources :cities, :collection => {:manage => :get} do |cities|
cities.resources :venues, :collect
If you can run a cron script, don't worry about actually doing
something in Ruby or Rails itself. Just write a bash script to check
the output of the 'gem rails' command for the appropriate version
number you use.
On Jan 3, 1:11 pm, Michael Satterwhite wrote:
> I have my rails sites hosted by Bl
You can break up common methods and place them in modules. Then simply
"include" the module in ApplicationController (or any other set or sub
set of controllers as needed).
On Dec 30, 10:39 am, vlain wrote:
> After six month of development and a first release we decide to
> refactor our applicat
I asked my boss what gem it was he determined we need to be on, he
claims "pr", so I tried to install it and it fails to compile, so now
im back to square one. I really thought I had this all sorted out a
few weeks ago, maybe it was on a different computer.
On Dec 28, 11:18 pm, An
It's not the postgres (psql) version thats the problem, its actually
the ruby postgres gem that ActiveRecord uses to connect to psql. I
will be in the office tomorrow and will check it out.
On Dec 28, 10:48 am, Richard Schneeman wrote:
> That does make sense given all i've read about this error,
It's actually a problem with the postgres gem. I ran into this the
other day at work, if I remember correctly you just need to switch
which gem you hav installed. Unfortunately I don't remember which one
to use and I'm not at the office.
On Dec 27, 11:57 pm, Richard Schneeman wrote:
> So thanks
why ignore the test dir? dont you want to share those?
On Dec 17, 10:28 pm, Ryan Bigg wrote:
> Github!
>
> All the entries from my .gitignore file:
>
> log/*.log
> log/searchd*
> tmp/*
> db/*.sqlite3
> db/sphinx/*
> config/database.yml
> test
> coverage
> coverage/*
> config/*.sphinx.conf
> conf
Don't forget about helpers. Helpers that take blocks are especially
useful, it's a really easy way to conditionally display some content
without cluttering the view.
# Helper
def is_authorized(action, resource, &block)
yield if current_user.permission_check(action, resource)
end
# View
<% is_a
I would say go for it. There are a number of ways to approach your
situations. A simple solution might be to create plugins with models
and controllers, and build a different app for each client, basically
providing the views and configuration. More complex and powerful
alternatives exist of cours
map.resources :images, :member => [:500, :1000]
will map to 2 methods in your controller, but I think you might have
problems giving ruby method names that start with numbers.
you probably just have to make a specially entry in your routes file,
something like this:
map.cached_image '/images/:i
Maybe I'm missing something, but it doesn't sound like you need
acts_as_taggable or single table inheritance. I think you will get the
desired result by setting up the ObjectRelations model as follows:
class ObjectRelations < ActiveRecord::Base
belongs_to :linkfrom, :polymorphic => true
belon
If you notice I only pass a section of the params has designed
specifically to build the appropriate query, not the entire hash.
On Dec 7, 5:22 pm, Leonardo <[EMAIL PROTECTED]> wrote:
> You're passing unnecessary knowledge to your model.
> It definitely doesn't need to know the controller and/or
Not necessarily. The params object is just a hash. There is no reason
why you can't or shouldnt pass a configuration hash to a method. I do
something similar quite often. One instance I find myself working with
is XML API's that I must generate. Many options are available on the
query string. To h
Sounds like you just need a line like this in the top of the lib file:
require 'app/models/aircraft'
If its already loaded (ie: running script/server) nothing will change,
but if its not already loaded (I don't use RSpec, but it sounds like
its not autoloading classes) this should fix it. You mi
The code to configure this is fairly trivial, try something like this
in the controller(s) you need subdomain access.
before_filter :load_account
def load_account
@account = Account.find(:first, :conditions => ["slug = ?",
request.subdomains.first])
raise ActiveRecord::RecordNotFound unless @
How and where are you executing the code in this lib from, rake task,
script/console, etc.?
On Nov 28, 12:10 pm, Christian Lescuyer <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I'm trying to verify that a parameter is an instance of a specific
> class in Rails:
>
> def schedule(action, *args)
> if arg.
I don't understand your question, are you trying to find a way to mass
mail people unique messages with unique attachments?
On Nov 27, 12:08 pm, Tom Ha <[EMAIL PROTECTED]> wrote:
> Hi there!
>
> What emailing solution (plugin, gem, script) can you suggest for the
> following situation:
>
> - mail
check out the google calendar API docs, instead of using mechanize and
scraping the page.
http://code.google.com/apis/calendar/docs/2.0/developers_guide_protocol.html
On Nov 27, 5:58 pm, kevin lee <[EMAIL PROTECTED]>
wrote:
> Hi I am working on a event calendar app that I would like a user to be
You can make named routes for everything using the technique Phillip
posted, you could rearrange your actions to be more restful (maybe a
sessions controller, and map login to sessions#create, or move your
default routes to a different position in the routes file (order is
important here).
On Nov
The solution you have seems like a fine answer to me. Simple,
standard, and should be pretty easy for any incoming developer to
understand. If youve got a method like the following then it probably
isn't a big performance drain either.
before_filter :intialize_session_stuff
def intialize_session_
class Model < ActiveRecord::Base
def raw_sql_query
connection.execute("select name from #{table_name}")
end
end
The above example will return something like this:
[{:name => "A"}, {:name => "B"}]
On Oct 29, 8:09 am, xxmithila <[EMAIL PROTECTED]> wrote:
> Hi all..
>
> please give m
If you dont want to get into memcache or other complex solutions you
can do something simple like this:
class StylesCache
include Singleton
def self.by_name(name)
self.instance.by_name(name)
end
def by_name(name)
return @active_style if @active_style && @active_style.name ==
nam
map.connect ":manufacturer_name/:model_name", :controller =>
"manufactuers", :action => "show"
in your controller params[:manufacturer_name] and params[:model_name]
should be available
On Oct 22, 6:27 pm, Grayson Piercee <[EMAIL PROTECTED]>
wrote:
> I know this isn't all that Rails friendly but
At work we do something similar, although we dont have issues with the
session_id using ActiveRecordStore. One approach you could take would
be to create a new object (Visitor), and store the visitor.id in the
session. Then use the before filter to load that Visitor on each
request. Then, create a
named_scope is your friend
class Download < ActiveRecord::Base
belongs_to :file
named_scope :between, lambda{ |start_date, end_date| { :conditions
=> ["created_at >= ? AND created_at < ?", start_date, end_date] } }
named_scope :from_file, lambda { |file| { :conditions => ["file_id
= ?", fi
check out this place: http://www.xhtmlized.com/
there are other companies that do the same thing, unfortunately this
is the only name i can remember right now.
On Oct 18, 10:44 pm, "Carla DeLuca" <[EMAIL PROTECTED]> wrote:
> thank you
>
> On Sat, Oct 18, 2008 at 3:17 PM, Alex <[EMAIL PROTECTED]>
ActiveRecord::Base.connection.execute( )
On Oct 16, 3:19 pm, Freddy Andersen <[EMAIL PROTECTED]> wrote:
> `mysql -uroot databasename < sqlfile.sql`
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Ta
Quite often I'm tasked with doing something very similar. Check out my
solution:
class ExperiencesController < ApplicationController
self.view_paths << File.join(RAILS_ROOT, "cms", "experiences")
def show
render :layout => "1/layout"
end
end
requiring a folder structure like:
RAILS_RO
if the application isnt starting it probably isnt a controller, most
likely something funky in your initializer (config/envrionment.rb) or
your actual environment file (config/environments/development.rb) or
possibly in a plugin you recently added. have you changed anything in
those 3 locations re
the advantage to the datetime based filenames over the simple integers
is that it allows you to work in branches, make migrations and merge
it all back together later without fear of conflicting migrations. why
would you want to go back?
On Sep 9, 8:45 pm, Trogdor <[EMAIL PROTECTED]> wrote:
> I w
ctiveSupport here is one big
> Singleton?! That might be a way to solve it as this functionality
> would perfectly fit in a Singleton. I will give it a thought
>
> Jan
>
> On 6 sep, 20:38, Andrew Bloom <[EMAIL PROTECTED]> wrote:
>
> > What I forgot t
od, or use the extend method and refactor your module a
bit.
On Sep 6, 1:34 pm, Andrew Bloom <[EMAIL PROTECTED]> wrote:
> if you are checking AccountSystem.account_system_type in your
> controller what is the point of including it in ApplicationController?
> If you plan to use it a
Have you seen: http://activescaffold.com/ ? It's not quite as
automatic as Typus, but it seems easier to customize. Guess it depends
on your needs.
On Sep 6, 11:33 am, "Luiz Vitor Martinez Cardoso" <[EMAIL PROTECTED]>
wrote:
> Yeah,
>
> I'm looking for some admin page like django. I found only ty
if you are checking AccountSystem.account_system_type in your
controller what is the point of including it in ApplicationController?
If you plan to use it as such, maybe you are better off making it a
Singleton Class.
If you actually want account_system_type to be a class accessor on
ApplicationC
56 matches
Mail list logo