I'm trying to extract some common code into a gem.
I'm thinking that acts_as_somethingis a good strategy for simple re-use.
Is there a good tutorial that discusses this for rails3 gems? I've found several that discuss rails2 (such as http://guides.rubyonrails.org/plugins.html) but that is specific to rails2
here are some of the tuto...
THE SITUATION:
I have code in lib/foo/bar.rb with a simple method defined as such:
module Foo
class Bar
def test
"FooBar"
end
end
end
In my helper, FooBarHelper, I have:
require `lib/foo/bar`
module FooBarHelper
def test_foo_bar
fb = Foo::Bar.new
fb.test
end
end
In my view, I call this helper method li...
I am trying to show a rails view file in a textarea. the view file contains a bunch of HTML, which I want to escape so that it does not interfere with on page html. here is an example:
In this view we are going to display the contents of a partial
<textarea>
<%= html_escape render('partial') %>
</textarea>
and in partial.html.erb I ...
Given:
<%=form_for [:project, @note], :remote => true do |f| %>
I'd like to create a jquery bind that automatically saves every few seconds. I'm not worried about the timing part yet, just how to use jquery to submit the form automatically (ie, not submit button click by the user.)
I tried this, but it isn't working. Suggestions?
$(...
I'm having trouble with the Authlogic-gem. Before I write my own auth-scheme I wanted to ask if anyone had the same problem:
When logging in it successfully executes the user_session.save and redirects, but the "current_user" is not set. It works perfectly locally, but it won't when using Passenger.
I updated Passenger to 3.0 but no lu...
Hi. Here's what I'm trying to do.
when the user clicks new note.. I want the user to be taken to a page when they can start typing a note, and save it to the server all with AJAX..
Problem is, every time the page saves, it's making a new note.
This leads me to believe that when Rails gets the DEF NEW controller, some how I need rails ...
I have installed RVM and as noted in the install http://rvm.beginrescueend.com/rvm/install/ I was able to get "rvm is a function."
A lot of what I've read recommends not to use sudo gem install bundler, but it did not work without sudo (the error said I was not able to write to var/lib/gems/1.8 with gem install bundler)
Even after "Su...
I added a table that I thought I was going to need, but now no longer plan on using it. How should I remove that table?
I've already ran migrations, so the table is in my database. I figure rails generate migration should be able to handle this, but I haven't figured out how yet.
I've tried
rails generate migration drop_tablename, but ...
Hi! Here is my Rails 3 nested routes structure for PROJECT
resources :projects do
resources :notes, :photos
collection do
get 'yourproject', 'newjs'
end
end
This works great for things like
/projects
/projects/1
/projects/1/notes/
/projects/1/notes/3
what isn't working is:
/projects/1/notes/newjs
Anyone Rails 3...
I am new to programming (previously only did html/css/design) trying to start learning RoR via the book Simply Rails 2. However I want to start with the most recent versions of Ruby(1.9.2) and Rails (3) so I am forced to get everything configured without the book. I have looked a lot via google and on stackoverflow. When I run rails serv...
Hello all, thanks for reading this post. I've been stuck on an issue with RoR for the past few days. I have a form under index.html.erb as:
Ajax List Demo
Listing posts
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
Add to list using Ajax
<% form_tag :action => :list , :method=>:get, :remote=>true d...
At the RMagick repo on Github, a message was uploaded yesterday saying the main author cannot continue to maintain the project, and is looking for new people to take over. (I would certainly crash it were I to ever attempt such a job!). You can see their readme here: http://github.com/rmagick/rmagick.
In your opinion, where should a Rai...
I currently have below lines for application_controller.rb. Basically, I am using session to check whether user has logged in or not, including authentication. I just used a term m
class ApplicationController < ActionController::Base
protect_from_forgery
protected
# Returns the currently logged in member or nil if there isn't on...
Hello. I'm getting ready to build search capabilities into my app. I want the search to have the ability to span multiple models.
I'm thinking about adding a search controller which would then decide which models to search based on settings etc...
What do you think? Does a search controller sound right or is there something open-source...
I'd appreciate any help with this - I'm sure it's a simple mistake.
The location of my app is C:\sanj\rubyjobs. I have installed ImageMagick successfully in its default location: C:\Program Files (x86)\ImageMagick.
I have also installed rmagick the gem by running gem install rmagick --local in C:\sanj\rubyjobs\vendor\RMagick Extract...
Hey!
So i just got devise and fb login to work on my rails project, but I would like to get more info about the user when they log in. I added user_about_me to the scope of the request and that got me a lot of info, but I would also like to get the users music/movies/etc. I tried adding user_interests but it doesnt seem to send anything...
I have a macbook that has Leopard (OS X 10.5) but don't have Snow Leopard.
It ran Rails 2.3.8 fine, but now when it comes to Rails 3.x, with Ruby 1.9.2 (or 1.8.7), gem install cannot build mysql, mysql2, or sqlite3-ruby, so essentially, this macbook can't use Rails 3.x at all? Is there a way? thanks.
(it seems that the latest Xcode ...
Hi, can someone help me look at this. Getting too tired.
class User
has_many :questions
has_many :choices
end
class Question
belongs_to :user
has_many :answers
has_one :choice, :through => :answer
end
class Answer
belongs_to :question
end
class Choice
belongs_to :user
belongs_to :answer
belongs_to :question, :throug...
For example, the following code:
class FoosController < ApplicationController
def index
if [email protected]?
render :locals => {:bar => @foo}
return
else
@foo = rand 10
render :locals => {:bar => @foo}
end
end
end
if I load localhost:3000/foos multiple times, it will show different values, and it is n...
Is there a reason why all sqlite3, mysql, postgres driver compiles on Mac OS X Leopard when it is Rails 2.3.8, but can't compile when it is Rails 3.x?
Theoretically, isn't it just some compile flags to make them work?
(They all compile on Snow Leopard with the latest Xcode, but can't compile with Leopard with a slightly older Xcode... ...