I want to create an open source banner/advertising management app using Rails. The app is like the simplified version of OpenX, where user can define the ad zone, upload banner, and paste the javascripts on the page to view the ads.
This will be my first open source project and using this opportunity to learn Rails. But I searched aroun...
I've got rails app I'm working on locally and uses geokit to talk to google and geocode addresses. I run the development environment using script/server (which runs mongrel_rails) on port :3000. Everything works just fine.
Now, I've setup a staging environment and cap deploy that to a diff directory on localhost via ssh. The deploy work...
in my rails app, I have an Organization model, with a reference to a User, which I want to be able to access via organization_instance.adminstrator. I'm not sure how to accomplish this using the belongs_to method.
...
My rails version is 2.3.5(2.3+)
How can I visit urls with .html suffix?
Just like localhost:3000/welcome.html (welcome is a controller).
I got routing errors when I visit urls above.But it works if the url with format param like this:
localhost:3000/welcome?format=html
In routes.rb:
ActionController::Routing::Routes.draw do |map|
...
Suppose you have a data model that is something like
class Question
has_and_belongs_to_many :choices
end
Now suppose, on that choices model, there is a position column. What is the best way to access that information without having horrible messy queries / models?
The beauty of has_and_belongs_to_many is that it keeps things concis...
Rails is great that it will support timezone overall in the application with Time.zone. I need to be able to support the timezone a user selects for a record. The user will be able to select date, time, and timezone for the record and I would like all calculations to be done with respect to the user selected timezone.
My question is wha...
On a vanilla Authlogic install set up a la Ryan Bate's Railscast #160, when a user goes to login and the session FAILS, the url changes from
/login
to
/user_session
(Of course, it shows the validation errors and all that jazz.)
I want to keep the URL always at /login, even on failure (and still display the login errors). How woul...
We have a medium size Java application that needs some refactoring.
We are considering migrating towards JRuby on Rails. Mainly because of the productivity that Ruby on Rails offers and for the many existing plugins that will reimplement the web logic.
However a large part of the application should stay in Java, we do not want to rewri...
I need to build an internal service that queues the DB for changes (in one table) every one second, and processed data after this event.
I do not need all the Rails stack since this service does not need the Controller/View functionality. Basically, from the rails stack, i only need AR (or an ORM).
The found solutions/approaches for t...
I have controller methods that look like this:
class TestController < ApplicationController
def testAction
render :json => { 'success'=>1 }.to_json
end
end
When I load this action in the browser, I get what I expect: {"success":1}
When testing with RSpec, however, response.body gives me '<html><body>You are being <a href="htt...
I have
<%=link_to distance_of_time_in_words_to_now(post.created_at), post %> ago
However I want to make 'ago' show up in link as well. Now its something like '20 minutes ago,' which kind of looks ugly. I want it to look like 20 minutes ago.'
I tried using #{} with no success and Google search turns out very little, especially since ...
I am currently trying to automate the deployment process of our rails app as much as possible, so that a clean build on the CI server can trigger an automated deployment on a test server.
But I have run into a bit of a snag with the following scenario:
I have added the friendly_id gem to the application. There's a migration that creates...
I've a post model with act-as-taggable-on gem. Both tables have timestamps.
I started with
def tags
@posts = current_user.posts.find_tagged_with(params[:tag], :order => "@posts.tags.updated_at DESC"])
end
And when that didn't work, I tried changing things and ended up with this mess.
def tags
@posts = current_user.posts.find_t...
I have a configuration file to which I want to add a string, that looks e.g. like that:
line1
line2
line3
line4
The new string should not be appended but written somewhere into the middle of the file. Therefore I am looking for a specific position (or string) in the file and when it has been found, I insert my new string:
file = File...
I've seen and googled and found many pretty url links.
But they all seem to look like http://example.com/users/username
I want it to be like github style http://example.com/username
Any directions that I can follow??
...
I am new to rails and ruby.
I have a has_many association between user and store
below is what I do:
@user = User.find_by_userid_and_password("someuser", "12345")
=> #<User id: 1, userid: "someuser", password: "12345",
created_at: "2010-01-25 00:00:00", updated_at: "2010-01-25 00:00:00">
@user.stores
=> [#<Store id: 3, store_id: 3, ...
I am developing a complex form that updates several records of one model at once, whilst simultaneously updating an associated model. It looks a bit like this:
class Sport
has_one :photo
end
class Photo
belongs_to :sport
acts_as_fleximage
end
class Page
# the page is not related to either of the previous models
end
Just for ...
In Ruby, I have a controller action that immediately initiates a computationally-intensive task that takes several seconds. I want the client to poll my server and get status updates.
in my controller:
def complex_task
Thread.new do
loop do
one_part_of_the_computationally_intensive_task
# Note how much progress we've ...
How do I see / change session data from within a thread within rails? See this code snippet inside my controller:
def controller_action
session[:something] = 'before' # works properly
Thread.new do
session[:something] = 'after' # out of scope. <--- how do I fix this?
end
end
(related to this question, but much more speci...
I've been following ryan baytes screencast #170 and adding ruby-openid, authlogic and authlogic-oid to an existing authlogic authentication system.
However, i keep getting the following stack of errors:
NameError (uninitialized constant OpenIdAuthentication::InvalidOpenId):
/Library/Ruby/Gems/1.8/gems/authlogic-oid-1.0.4/lib/authlo...