I'm trying to call a custom instance of a 403 HTTP error in Rails but I can't seem to figure out how to do this...
I have several user authentication roles and basically if a role tries to browse to an area that it is not authorised to visit I want to display a 403 instead of just redirecting the user.
How do I do this?
...
I have this in my controller. I need my view to generate some HTML, which I then convert to a pdf using Flying Saucer (Im using JRuby). This then gets returned to the client.
def show
@cs_agreement = CsAgreement.find(params[:id])
respond_to do |format|
format.pdf do
# TODO there must be a better way of getti...
In ApplicationHelper I have such code:
def inside_layout layout = 'application', &block
@template.instance_variable_set '@content_for_layout', capture(&block)
concat \
@template.render :file => "layouts/#{layout}", :use_full_path => true
end
which behaves like this:
application.html.haml:
!!!
%html
%head
...
%body
...
Hi everyone.. i've been looking for a solution for weeks now. yet still failed..i have stored procedure that was called using in ruby on rails..in that stored proc i have validations and thrown using raiserror.
ex. raiserror("StartDate must be less than EndDate")
in my ruby on rails controller
def save
begin
M.find_by_sql "EXEC spT...
I have a couple of views I'd like to have appear on every view that is rendered, but short of duplicating code or breaking the specifications, I can't seem to find a way to accomplish this.
Here's my current code, putting calls in every view:
def ImOnABoat::Views
def layout
html do
head do title "Petstore" end
body...
Hi,
I'm kinda new to Flex. I have trying to send Hash from Ruby on Rails application to Flex using RubyAMF.
Results look like this:
result (mx.utils.ObjectProxy (@22b207d9))
|
|-->errors (object (@16c64dd1))
|-> Name -----"Name is too short"
|-> Email-----"Email has already been taken"
|-> Password--"Password is too sh...
I am new to rails. My rails version is 2.3.5. I found usage like:
In controller, a destroy method is defined and in view, you can use :action => "delete" to fire that method. Isn't the action name has to be the same as the method name? Why delete is mapped to destroy?
Again, in my controller, I define a method called destroy to delete ...
I am trying to get heroku running on Unbuntu 9.10
I typed
sudo gem install heroku
and everything works fine but then when I go to run:
heroku list
I get
heroku: command not found
...
New to rails. I am using form_for helper in rails 2.3.5. The question is, when editing a record, I cannot use:
<% form_for :myrecord, :url => {:action => :update} %>
...
<% end %>
But I have to use:
<% form_for @myrecord, :url => {:action => :update} %>
... # the same as above
<% end %>
When I use the first code, it a...
I am looking to set up a Redmine server on a Windows virtual machine on my local workstation. (Background in this related question.)
I have zero knowledge of Ruby nor Rails, and while Redmine may be the opportunity to dip into those platforms somewhat, my first goal is to get it running as quickly and easily as possible. For that, I am...
The following question is related to passing a variable from routes to the controller. I have a Ruby on Rails (v 2.3.3) app with one model, which is delivered to the user with multiple views. The current solution involves using multiple controllers which are triggered by multiple routes. For example:
ActionController::Routing::Routes.dr...
I'm using the ancestry gem to structure some groups in a tree. At the same time I'm using acts_as_list to keep groups at the same tree level in a sorted list. Given the following model:
class Group < ActiveRecord::Base
acts_as_tree
acts_as_list :scope => "ancestry"
named_scope :parentable, :conditions => "NOT type = 'PriceGroup'"...
Trying to Google around for an a Rails plugin that will allow for throttling the amount of requests a particular resource gets consumed. Django's Piston has some open source code for this. Is there something available out of the box for Rails or is it safe to assume that looking at how Piston does it and porting it as a Rails plugin is s...
What is the proper way to register users automatically when they log in with openid?
I am using authlogic with an authlogic-oid gem (and an older version of openid_authentication).
The stuff I read online so far seems to be obsolete.
Does anyone know the proper way to do it with the new gem?
What I do now is:
options = params[:user_s...
Hey guys, I have a program that uses ajax to send a post to multiple social networks via their APIs based on user form input. I was wondering if this process (which doesn't take more than 2-3 seconds when I test it myself) is worth daemonizing with something like BackgroundRB? In other words, were this program to become used by 100+ peop...
Let say, I have a web application that allows users to upload images and documents and my application stores all those assets on S3, is there a way I can monitor resource usage PER user account?
For example, if a user account has a 1GB storage limit, how can I monitor how much of that allowance any individual is using?
Furthermore (but...
I'm trying to write a plugin that will extend InheritedResources.
Specifically I want to rewrite some default helpers.
And I'd like it to "just work" once installed, w/o any changes to application code.
The functionality is provided in a module which needs to be included in a right place. The question is where? :)
The first attempt w...
Hi all-
I am creating a site similar to the infamous Woot in one particular way: I would like to rotate through products at a rate of one per day. I am using RoR, and would prefer to dynamically choose a product, and not have to enter one each day. So here are the requirements:
1) Get a new product each day
2) Select dynamically f...
After reading http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html I just can't seem to find what I'm looking for. I have a simplistic model that deletes the oldest message after the list of messages reaches 24, the model is this simple:
class Message < ActiveRecord::Base
after_create :destroy_old_messages
prot...
In my rails application I have a helper function:
def render_page( permalink )
page = Page.find_by_permalink( permalink )
content_tag( :h3, page.title ) + inline_render( page.body )
end
If I called the page "home" with:
<%= render_page :home %>
and "home" page's body was:
<h1>Home<h1/>
bla bla
<%= render_page :about %>
<%=...