You are currently browsing the tag archive for the ‘Plugin’ tag.
One pillar of my high code-coverage is this little plugin, which allows you to simply state that a controller or a action should behave RESTfully.
So far it is experimental, meaning it works on my machine ![]()
Any testers and contributes highly welcome.
Install instruction and usage.
Example
describe UsersController do
before :each do
login_as :quentin #if your controllers need login
@item = @user = stub_model(User)#or anything else that has a to_param method
end
behave_like_resource
end
I just made a partial like
bla bla =yield something else
and to my surprise
render :partial=>'yield_partial' do something for the inside end
did not work!
So i got myself better partials
Install
script/plugin install http://betterpartials.googlecode.com/svn/trunk/better_partials/
Usage
- partial "yielding_partial" do %h2 Damn old partials
and it works
PS: that not erb but haml code
If normal rspec profile output is not enought, try this enhanced rspec profile formatter!
Example
Groups: 5.1150300 Movie 4.9603220 Icon 1.7279670 User 1.4466160 Person ... Single examples: 4.8707710 Icon refresh! resizes existing thumbs 0.9086340 Review releases the movie 0.5203390 Movie finds invalid ...
Install
script/plugin install script/plugin install git://github.com/grosser/rspec_enhanced_profile.git #add to spec/spec.opts: --format RspecEnhancedProfile:tmp/profile.txt
All my ‘Ajax’ requests, use simple xhr when they want to load html, and not .js ,which imo is a misuse since requesting .js should yield a json response.
The first thing i always do is define a xhr layout, which usually is nil. Who ever thought that any xhr request should ever respond with stylesheets and javascript?
layout proc {|controller| controller.request.xhr? ? nil : 'application' }
Working this way i came to some limitations of the xhr approach:
- cannot easily request from the browser
- cannot redirect
Redirect an xhr ?
When a user requests something in a Lightbox, it is render using xhr. When the requested resource is not accessible by this user, he should see a login screen. This can be done with a normal redirect, which the JS Framework(at least jQuery does) uses to render the login page inside the lightbox.
Sounds good? But does not work…
Redirects will have the default layout, since they are no longer xhr request, which messes up the lightbox.
Xhr redirects
With this xhr redirect plugin the problem should go away.
_xhr=1
The plugin uses an added parameter _xhr to signal if a request is xhr or not, so now one can also request a page with _xhr=1 and see the actual xhr response.
UPDATE
acts_as_searchable is no longer maintained, please switch over to the new and healthy world of search_do bug-free, clear structure and paginating!
Just relesed another small plugin, to help integrate acts_as_searchable and will_paginate
Movie.paginate_by_fulltext_search( params[:q], :page=>params[:page],:per_page=>10 ) script/plugin install http://small-plugins.googlecode.com/svn/trunk/will_paginate_acts_as_searchable/
