Displaying 20 results from an estimated 1200 matches similar to: "DRYing up the view"
2006 Aug 04
4
DRY DRY DRY
Hello everyone!
Ive been on rails for the last month or so and really enjoyed this
framework.
However its very hard to find documentation on how to do things right!
For example every beginner after a while realizes that having similar
CRUD actions in every controller and views for them is not DRY at all!
Few days ago I found http://dereksivers.com/rails-shared-controller.html
I quite like his
2005 Aug 18
10
Scaffolding, DRY and RHTML
Hello all, I''m working on a couple of Rails projects at the moment and
have noticed something that seems to go against the DRY principal.
Why, when scaffolding, are individual CRUD rhtml files created instead
of using one as a partial and having the others use that single
partial? This especially applies to the list rhtml. I am about to get
to the other operations and see how feasible
2007 Oct 14
1
Story Runner: DRYing items used in many stories
The number of stories I have is growing and I''m writing the following step
long hand in each story.
Given ''a user named'', ''Andy'', ''Watts'' do |first_name, family_name|
@email = first_name + ''@test.lan''
create_user( :first_name => first_name, :family_name => family_name,
:email => @email )
2007 Dec 09
4
Help on drying code
Hi all,
Currently I''m having to do this:
def self.authorized_roles(controller, action)
specific = self.find_by_controller_and_action(controller, action)
all_actions = self.find_by_controller_and_action(controller, ''*'')
all_controllers = self.find_by_controller(''*'')
role_ids = []
specific.each do |role_item|
role_ids <<
2006 Aug 08
1
Cascading views?
For some fairly generic views and controller stuff I''d like to have a
standard view, say app/views/shared/list.rhtml, and a way to override
it per controller, app/views/mymodel/list.rhtml.
I think I''ve read of a similar feature before, but I''m not really sure.
I may be confusing things with engines and productize. Has someone
implemented it for plain Rails apps?
2006 Aug 14
1
What fields_for really for?
Hello everyone!
I have 3 models:
=== 1 ===
class Region < ActiveRecord::Base
has_many :districts
end
=== 2 ===
class District < ActiveRecord::Base
belongs_to :region
has_many :suburbs
end
=== 3 ===
class Suburb < ActiveRecord::Base
belongs_to :district
validates_numericality_of :region_id, :only_integer => true
end
In edit.rhtml for SuburbController I need to specify
2008 Jan 23
13
DRYing up stories
I''m finding that I''m writing sets of very similar scenarios to check access
permissions for each of my actions. Does anyone have suggestions on how to
dry this up:
Given an existing Account
And a logged in Admin
When the user visits account/manage
Then he should get access
Given an existing Account
And a logged in Manager
When the user visits account/manage
Then he should get
2011 Apr 18
0
Drying my code ..
I am parsing an xml result using Hpricot, amazing ..
I have a serie of tags to be transformed as parameters, so I am
building Hash by looping on these tags , the resulting data is oK? but
I ma not sure that I wrote a dry code
.......
if doc.search(''response > error'').innerHTML.empty?
accountTypes = []
(doc/:accounttype).each do |accountType|
2008 Jun 13
0
DRYing some controller code
def index
if not @contest.nil?
@videos = Video.paginate( :all, :include => { :ad
=> :contest }, :page => params[ :page ],
:conditions => [ "videos.state = ''published'' AND
contests.slug = ?", @contest.slug ] )
else
@videos = Video.paginate( :all, :conditions => { :state =>
''published'' }, :page
2007 May 30
0
DRYing up controller tests and mailer tests using superclasses
Hi!
Currently both, the controller/functional tests and mailer tests,
contain a lot of cruft. I''ve created two superclasses to DRY them up a
bit. Here are some examples how tests using those superclasses will
look:
http://pastie.caboo.se/66139
Ticket with the patch:
http://dev.rubyonrails.org/ticket/8521
Known issues:
* Since we don''t explicitly setup the @request and
2010 Jul 04
2
DRYing Routes
I have a series of ''static'' pages for a site that need named routes in
Rails 3. I''m trying to DRY the routes file, but can''t seem to find the
proper code.
The desired output/code is:
match ''/about'' => ''info#about'', :as => :about
for each page. My attempt to dry this:
%w(about services articles marketing clients).each
2008 Apr 24
3
DRYing up controllers
Hi
I''m a big fan of plugins such as Resource Controller
http://jamesgolick.com/2007/10/19/introducing-resource_controller-focus-on-what-makes-your-controller-special
However, recently decided I don''t want to depend on a plugin for this,
and would rather stick closer to the rails core.
So does anyone have any cool strategies or ideas for achieving this?
Or is there any move to
2006 May 16
3
wondering how to do some clever DRYing up
Hi there,
I''m now getting to the point in my rails app where I can use all of the nice basic features like AJAX and engines etc...
but, I want to get my hands a bit dirtier, whilst learning to DRY up my code a bit.
I''m using AJAX quite a bit to dynamically populate/edit/sort has_many relationships in forms, and consequently on a model with many has_many''s I end up
2006 Apr 01
3
Gracefully degrading Ajax AND Drying up actions
Still a semi-newbie, but so far I''ve managed to solve most things with a
bit of help from the Agile book, some googling around, and a bit of
trial-and-error, but I''m really stuck with this one (very much an Ajax
newbie):
I know how to gracefully degrade an AJAX newpost type call so it can
appear inline or (for those without JS support) go to a new page (put an
":href
2006 Jul 25
12
DRYing - similar named fields, etc.
I''m sorry - just couldn''t come up with a subject that describes the
problem :(
Anyway, this is my problem. I have a long list of fields that need to
be displayed when a ''show'' is requested on the controller. I''m now
doing the list.rhtml and looking for a DRY way to do the following.
For each data item, I have 2 fields - one is the item name, the
2010 Apr 06
2
respecting original matrix dimensions
Hi All,
I'm hoping someone else can help me out with this. I am doing some
matrix algebra using sub-parts of matrices, and sometimes I need only
a single row/column of the original matrix. However, whenever I pull
out only a single row/column, R returns a row vector, but often this
will break my matrix algebra. Is there any *easy* way to get R to
remember what the single row/column came out
2007 Mar 24
1
spec''ing metaprograming & rails CRUD
For edge rails there is a Crud generator. There is also a CRUD
controller that is out there from which you can inherit your other
controllers (see http://geekonomics.blogspot.com/2006/07/crud-and-
shared-controllers.html)
This got me thinking about Crud controllers in general. As far as I
know, the generator can''t produce crud classes which are nested
(i.e.
2007 May 04
11
spec template for CRUD?
Hello,
Has anyone already come up with a set of shared behaviours that
someone could leverage when adhering to a CRUD concept, with respect
to controllers?
Relatedly, it would be nice if there were a way to share generalized
behaviour specs.
-Chris
2007 Mar 19
3
controller_name with dynamic controllers
I''m writing a controller which should only be inherited from,
something like the generic crud controller seen here: http://
geekonomics.blogspot.com/2006/07/crud-and-shared-controllers.html
Now, in my spec, I would like to create a controller which inherits
from the generic CRUDController, without actually creating the
controller. This controller is *only* for testing.
How can I
2006 Mar 03
2
newbie scaffold question
I''ve got a database with several tables. I''d like to create scaffolding
for separate CRUD interfaces for several of these tables. I''m hoping
that the scaffold generator can create the CRUD code for all these
tables in ONE controller, but I don''t know how to tell it to do that, if
it can.
Can anyone verify if this is possible?
Thanks,
David
--
Posted via