similar to: DRY - in controller or model????

Displaying 20 results from an estimated 2000 matches similar to: "DRY - in controller or model????"

2008 Jan 21
9
DRY act_as_authenticated functional testing
I''m using the acts_as_authenticated plug-in for my app. Now I need to get my functional tests to work properly. I have not written functional tests before so I''m unsure how to utilize setup so that all of my tests can use the login. My tests pass if I put login_as :user inside of each test, but that''s clearly not DRY. Can I add something to my test_helper.rb file or
2008 Mar 07
6
creating a model registry
Hi all, This is a problem I''ve approached so many times and always worked around, that now I want to solve it once and for all. Say I have something like this: --- class X < ActiveRecord::Base acts_as_wacky end module Wackinator class ControlAllWackos @@wackos = [] def self.kill_wackos @@wackos.each(&:kill) end end def acts_as_wacky
2008 Mar 04
3
remote_form_for does not work with method = :get
It seems that remote_form_for does not work with method = :get since it does not change the prototype call. Is this a bug? --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe
2008 Feb 23
3
Attachment_fu: how to remove images?
I just used attachment_fu for the first time, and it works quite well. I have a user-model, and each of them has_one :image (and the images belongs_to :user). I have a question on this though: how can i remove images? Whenever i set a new image for a user (a user who already has an image), then the table with images gets updated correctly, with the user_id column of the old image set to null, and
2008 Apr 29
10
Better way to remove value from list??
I''ve got a field in a database that contains a string of ids. I want to be able to remove an item from that list and save the list again. The only way I saw how to do this was to convert it to an array and back to a string again. The variable names are for an example. This code works, but I don''t think that it''s efficient. It''s all in my controller.
2009 Sep 24
5
Non-ActiveRecord based model being passed as string?
I have a model that looks like this (with various other methods) class HsdPair attr_accessor :hsd def initialize(hsd) @hsd = hsd @current_display = 0 @has_changed_flag = false end end After initializing this object in the controller @hsd_pairs = HsdPair.new(@job.hsd_pairs) using it in the view various times and in various ways, when I try to pass this object back to the
2009 Aug 07
4
ActionController::UnknownAction (No action responded to 22.
I try to switch my application from Rails 2.2.2 to Rails 2.3.3. In namespace :admin I have a resource-based controller. See controller class Admin::OSystemsController < Admin::BaseController def index ....... end def edit ......... end def update .......... end end Resource is added to routes.rb like map.namespace :admin do |admin| ............ admin.resources :o_systems,
2008 Feb 25
4
Using group in with find in an ActiveRecord appropriately
I''m playing around with the Practical Rails Projects code, and was attempting to make a change for graphing data differently using groupings. Basically the code went from: total_weight = @exercise.activities.collect {|e| e.repetitions * e.resistance} workout_dates = @exercise.activities.collect {|e| e.workout.date.to_s} To: total_weight =
2009 Aug 06
18
Best Practices Question
Should models call action mailers, or should those calls always originate from controllers? For example, should user.forgot_password send the email, or should the user_controller.forgot_password? Just looking for some opinions... Thanks, Tom
2009 Oct 28
2
What's the simplest way to use ActiveResource in ruby (without rails)?
I would like to use this class in a standalone project, but I have been unsuccessful thus far. Also, how does this class exactly communicate with the web server? Thank you. class Person < ActiveResource::Base self.site = "http://localhost:3000/" end
2008 Feb 29
7
Moving pagination to the Model
I''m using will_paginate in a Post class method; [code]def self.list(page) paginate :per_page => 10, :page => page, :include => :user end[/code] I can happily use the method on my posts controller index action; [code] class PostsController < ApplicationController def index @posts = Post.list(params[:page]) respond_to do |format|
2006 May 01
5
Adding classes without script\generate
Can I add classes to a rails application manually i.e without using script generate Model/Controller? The reason I am asking, I added a class by putting it in the controller class. I can access the class and its method from command-line (irb), but when I try to instantiate it in another controller, I get "uninitialized constant" error. If I try using script\generate Model
2008 Nov 20
1
My ignorance and Fuse (or glusterfs)
I have a very simple test setup of 2 servers each working as a glusterfs-server and glusterfs-client to the other in an afr capacity. The gluster-c and gluster-s both start up with no errors and are handshaking properly.. One one server, I get the expected behaviour: I touch a file in the export dir and it magically appears in the others mount point. On the other server however, the file
2007 Jan 03
3
Self-referential habtm with condition is broken
Here''s a simplistic model class. class Person < ActiveRecord::Base has_and_belongs_to_many :relatives, :class_name => ''Person'', :join_table => ''relatives'', :foreign_key => ''from_id'', :association_foreign_key => ''to_id'' has_and_belongs_to_many :brothers, :class_name =>
2008 Apr 25
5
Best way to pass ID variable to partials - global var??
I have several orders that are being updated in an internal data entry app. I start by going from an order to pop-up form that allows a user to select items to add to a field in the order. The pop-up form contains 2 partials for drag and drop functionality from AWD. The user starts by selecting a category in a drop down list. Then on select, the first partial is filled with the list of
2008 Mar 14
2
Random image based verification for new user creation
Hi all, I''m creating an email list managed by my CMS. I''m wondering if people had any thoughts about securing it? I''m just concerned that my application server might be overwhelmed by requests to add to the list by a spider, etc. Am I being overly concerned or is that a real possibility? I was thinking of adding an image with a random sequence of numbers or letters
2004 Feb 28
1
when .Call can safely modify its arguments
Hi, "Writing R Extensions Guide" clearly states that a C-function interfaced via .Call() should not modify any of its arguments. However I wonder if there are exceptions to this rule, i.e. when .Call can safely modify the arguments. For example when a function creates a list that is then populated by a call to a C function: getData <- function() { data <- list(a=double(2),
2008 Apr 05
3
MySQL Unit Test Login Failure
I just recently started having issues running unit tests for my application, but can''t figure out why. When I run rake test:units, I get "Access denied for user ''root@localhost'' using password: NO". My database.yml file is configured to use the ODBC login, but it''s not being passed to my unit tests. Any ideas? development: adapter: mysql
2008 Mar 08
9
Validation error handling on related models
I have 2 models, entity and client. Entity has_one client and client belongs_to entity. Entity has attributes name and legal_name. Entity also has an unique index on (lower(name)). The pKey for both is the conventional Rails id. Client has a fKey constraint on entity_id and is indexed in entity_id. In controllers/clients_controller.rb I have: # GET /clients/new # GET /clients/new.xml
2006 Dec 04
7
I need help to connect Postgres and Ruby on Rails Please.
Hello to everyone, I have a problem that is giving me a headache, and trying to do a project in Ruby on Rails and I need to connect with a Data Base that is en Postgres, the truth is that I didn’t think that it was so hard to connect a DB with postgres because I was working with Msyql and everything was easy. This are the thinks that I have install in my computer. 1. Debian GNU/Linux, kernel