In a controller in my Rails app, I can do this:
before_filter :login_required, :except => :index
But I would like to apply the filter not only based on the action name but on the format of the request. In other words, I would like to do something like this:
before_filter :login_required, :except => {:action => :index, :format => :js}...
I am on Instant Ruby on Rails Mysql version 5.0.27, developing a system and all was going ok (sort of). Now the database keeps dropping. I found some comments that the userid needs to be root and password blank, I had changed the password, so I changed it back.
Views run fine displaying and making changes than 500 Internal error, log say...
I installed some new gems for testing and ran into an uninitialized constant ActionController::Dispatcher::MiddlewareStack error. I followed the instructions on the gem rdocs-specified the gem dependency in my environment.rb file and then ran rake gems:install and rake gems:unpack.
I also copied over my environment.rb file one line at ...
I want to give users the ability to page through my blog posts in random order.
I can't implement it like this:
@posts = Post.paginate :page => params[:page], :order => 'RANDOM()'
since the :order parameter is called with every query, and therefore I risk repeating blog posts.
What's the best way to do this?
...
I like all the default routes that are generated by Rail's map.resources. But, there are cases where I would like to use a non-numeric identifier in my routes. For example, If have a nested route consist of users and their articles, a standard route could be written as such:
map.resources :users, :has_many => [:articles] # => e.g. '/us...
For example, the comments in SO shows the number of allowable characters remaining. Basically, how do I do that in ruby on rails?
...
Hi,
I did a quick Google search and didn't see anything super-great to automate creation and updating of my google sitemap for the ruby on rails app. Any suggestions?
...
In my routes.rb file I have a number of routes. I would like to know which one got matched for any request a user may have made.
For example, in routes.rb you have the following routes :
map.connect ":controller/:action"
map.connect ":controler/:action/:id"
and if I have a controller named a and an action named first, when a user g...
I am using the FCKEditor wysiwyg editor, and was wondering if anyone figured out how to use the absolute path instead of relative path after you add an image in the editor?
And if so, how.
...
I have a string that may have a path to a file. Example src="/folder/whatever". How do I replace that path with src="http://www.sitename.com/folder/whatever ?
...
I have a Show model that has_one :venue, which is accomplished with each show having a venue_id
And my Venue model belongs_to :show
However I am having a problem accessing the venue by doing show.venue
Consider the following code where s is a Show instance
logger.info("*********************")
logger.info("#{s.inspect}")
...
Hello,
I have a mongrel server running behind Apache. It works fine; however, every now and then the Apache server shuts downs seemingly by itself. I'm not sure if there is configuration issue or if it's an attack. Here is Apache error log:
[Thu Apr 30 02:15:07 2009] [notice] SIGHUP received. Attempting to restart
[Thu Apr 30 02:15:0...
I need to output a file in the format of a Word document from a Ruby-based web app (Rails/Sinatra) based on some textual content in the app. Is there library support in Ruby for creating and structuring a Word document?
...
Hi~
I had a problam, Ruby on Rails Cache in ApplicationController.
The data can't get,but it's exist.
class ApplicationController < ActionController::Base
before_filter :init
def init
@setting = Rails.cache.read("data/setting")
if not @setting
@setting = Setting.find_create
Rails.cache.write("data/setting",@sett...
I have a rather unique class that allows its child classes to declare virtual fields. The child can declare virtual fields stored as XML by calling a method of the parent class like this:
class Child1 < Parent
create_xml_field ["readings", "usage"]
end
I have managed to get it working via a nasty work around. The create_xml_field me...
Saw this piece of code in a RoR book. This first one is from a View and the second one is a helper module. I don't understand how that &block and the attributes={} thing work. Can anyone guide me to a tutorial of some kind explaining this?
<% hidden_div_if(@cart.items.empty?, :id => "cart") do %>
<%= render(:partial => "cart", :object ...
Hello all,
We would like to implement a feature by which users could send an email to an application specific address and we will parse the message and take certain actions on it, similar to 37signals's backpack (and probably some of their other apps).
If anyone has done something similar, could you fill me in on how you did so? I'm un...
Here is a screen shot of weird characters in my database. I know that this character combination is for a crazy apostrophe. Should I just let these characters stay in my database? Or should I strip them out and replace with normal apostrophes?
If I should strip, is there on ruby function to ensure that all characters that save to my d...
I have some text/images that I only want to display in the normal state of a form -- that is, it hasn't been submitted, yet. If the user submitted the form, and it is returned to the browser with errors, I'd like to display something else. Currently, I'm using:
<% if [email protected]? -%>
# Leaving this area blank.
<% else -%>
...
Hello,
I'm using Ruby on Rails to make an application where businesses can create accounts and add information about their clients. I would like to be able to generate a form that they can put on their website to automatically enter the clients' info into their account. I know I might be able to do something like:
<% form_tag my_site_u...