similar to: Controller spec: testing that scope is set

Displaying 20 results from an estimated 700 matches similar to: "Controller spec: testing that scope is set"

2012 Apr 25
2
Rails 3.1 - Scaffolding Files
Where can I find more information about the new syntax on these: <%- model_class = @product.class -%> <h1><%=t ''.title'', :default => t(''helpers.titles.new'', :model => model_class.model_name.human, :default => "New #{model_class.model_name.human}") %></h1> <%= render :partial =>
2006 Apr 03
4
Clearing out filters in ActionController
I want to run a single filter in my application.rb file, and then if a certain condition is true, end the action''s processing immediately. Right now I''m using prepend_before_filter to ensure that it gets run first, but some of my around_filters are still being processed. Is there a way that I can clear out all the filters that should be run? Basically it''ll look
2007 Aug 21
2
using restful_authentication current_user inside controller specs
I''m using restful_authentication in my app and I have the before filters in my application rhtml: before_filter :login_required around_filter :set_timezone around_filter :catch_errors Currently I have them commented out while rspec''in but I''ll need to add them in my specs. def create @ticket = Ticket.new(params[:ticket]) @ticket.user = current_user if
2006 Jun 08
3
Macros and stuff
I was looking at my controller code and the edit/create/update/new for each are practically identical. So first I DRY''d the four methods in each controller to just one and then I decided to write a single macro for all my controllers. This is the macro: def self.edit_action_for(model, options = {}) model_class = Object.const_get(model) define_method(:edit) do
2006 Apr 18
4
how would you take the duplication out of this?
i have these two really similar methods in my addressbook controller. def edit_company @company = Company.find(params[:id]) if request.post? and @company.update_attributes(params[:company]) flash[:notice] = ''Company was successfully edited.'' redirect_to :action => ''show'', :id => @company end end def edit_person
2007 Mar 29
21
a better "should have valid associations"
This is pretty much the same as last time around, if you recall. Thanks to Wilson for converting to the new form. I''ve added a few lines. Basically, it iterates over your model associations and does two things. - First, just try to call the association. Usually fixes speeling erors or other such silliness. - Second, try to find a record with an :include on the association. This
2005 Aug 22
8
Observing changes to a text field
I''ve noticed that using several TimedObservers (prototype.js) on a page to watch for changes to text fields (haven''t tried forms) can have a non-negligible effect on the CPU cycles used by the browser process. Nothing dramatic, to be sure, but unnecessary. Autocompleter.Base (controls.js) follows a smarter strategy to watch for changes. Currently this functionality is tied
2008 Sep 13
2
<meta http-equiv="refresh" content="5"/>
Do you know of any way for me to stick a meta tag in using a before_filter or after_filter or around_filter? <meta http-equiv="refresh" content="5"/> I have been trying to figure out out and just cannot make sense of it. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2008 Sep 24
3
caches_page :if not executing (but caches_action :if) does
Hi folks - Seeing a weird problem and would love some help. It''s documented in http://pastie.org/278310 to be more readable. In short, I have a caches_page "action", :if => {stuff} but the :if is never being called - the action is just caching every time. (If I put a debugger call in the :if block, it never stops.) If I replace caches_page with caches_action, the if
2005 Aug 13
4
Timing out ajax requests?
Has someone come up with a generic way to handle ajax requests that exceed a certain time? In my concrete case, I have several select boxes for drilling down a hierarchy. When the user clicks an option, the next deeper level is retrieved. To avoid multiple concurrent requests, I disable the select box. As the request may take too long or cause an error, I set a timeout that re-enables the
2006 Jul 27
9
Introspecting validates_presence_of
Hello people, I''d like to detect whether an attribute of a model has vaildates_presence_of applied to it so I can automatically apply a mandatory (*) to the field...it doesn''t look easy...any ideas? Cheers, -- Dan Webb http://www.danwebb.net
2005 Jun 29
2
Unit testing
Recently, I''ve started to write unit tests for some of my scripts. In general,it''s no worse in JavaScript than in Ruby or Java. I didn''t have the courage to try Selenium, but had a look at JsUnit. Unfortunately, in Konqueror it produces unfathomable errors and in Firefox it is slow beyond imagination. Anyway, writing tests for functions that are computational or
2005 Sep 06
4
url_for: :overwrite_params went missing
Somewhere between 0.13.1 and the current SVN version the :overwrite_params option to url_for (and related methods) went missing. I can''t tell whether this was deliberate or by mistake, and I have no idea how to get the same functionality in some other way either. Michael -- Michael Schuerig Life is what happens
2006 Aug 08
7
Useful plugins for RadRails
Hi Friends, Could anybody suggest me some nice and useful plugins for RadRails! It would be very great if we make list of all such plugins! 1)________ 2)________ 3)________ 4)________ 5)________ 6)________ 7)..... Please fill above blanks and lets make a big list of it! -- Don''t live to geek; geek to live. http://anilw.info -------------- next part -------------- An HTML attachment
2006 Jul 28
4
Validation Reflection plugin
The validation reflection plugin adds three things (1) Reflective access to validations - ModelClass.reflect_on_all_validations - ModelClass.reflect_on_validations_for(:property) (2) It provides "declarative" methods for defining validations based on database metadata - validates_presence_of_mandatory_content_columns - validates_lengths_of_string_attributes -
2005 Sep 13
12
PDF views?
I know there''s wiki page on generating PDF[*], but that''s not really what I want. I don''t need to create arbitrary PDF. What I''d like to do is create PDF templates and fill in the blanks. Roughly, I''m looking for functionality akin to the mail merge feature of word processors, including conditional and repeated elements, say, table rows. Michael
2005 Aug 04
10
Rails Spin-offs WIKI.
http://rails-spinoffs.bombdiggity.net/index.php?title=Main_Page guys here is the wiki. Once you register let me know and I''ll give you full access to the site. Jon Jon Whitcraft Online Services (317) 492-8623 -------------- next part -------------- An HTML attachment was scrubbed... URL:
2010 Jan 27
1
around_filter and with_scope
i got two controller (with restful actions) where my code is quite ugly and not very dry. every action looks quite like this: if @logged_user.has_role?("admin") User.find(params[:id) else @logged_user.group.user.find(params[:id]) this is a security check that enforce a simple spec: normal user should read/write information only about their group''s users, but
2006 Jul 27
9
CalendarHelper
Has anyone had any luck using the CalendarHelper plugin at http://wiki.rubyonrails.com/rails/pages/CalendarHelper recently? I''m scratching my head over the following error when I look at any page in my application: NameError in CalendarController#index undefined local variable or method `date_format'' for #<CalendarController:0x24ccd4c> RAILS_ROOT:
2006 Jul 28
12
MenuEngine
Hi all, MenuEngine is a small Rails engine that can generate templated drop-down DHTML menus commonly used for web site navigation. Supports creation of menus from a YAML file, from code and from pre-configured HTML. Optionally integrates with UserEngine for authorization. http://www.muermann.org/ruby/menu_engine Project page: http://rubyforge.org/projects/menuengine This is my first attempt