I've been able to get haml working for a few of my views just fine, but try as I may, I'm not able to get application.haml to render a layout.
Right now I'm focusing on a very simple controller with one view (index).  The view itself renders fine but none of the code within application.haml works.  I've also tried renaming to applicatio...
            
           
          
            
            I have a Rails 3 App.
When the user is not signed in... I want devise to show non-signed in pages: SignIn, register,  about us, blog etc...
When a user is signed in I want it to go to the web app
where do I make this switch and how do I set it up? thanks
...
            
           
          
            
            This question relates to this SO question and answer (rails-3-ssl-deprecation
)  where its suggested to handle ssl in rails 3 using routes.rb and routes like:
resources :sessions, :constraints => { :protocol => "https" }
# Redirect /foos and anything starting with /foos/ to https.
match "foos(/*path)", :to => redirect { |_, request|  "...
            
           
          
            
            I'm trying to add some syntax highlighting to my blog that currently uses RDiscount. I am converting the Markdown to HTML with RDiscount then parsing the HTML code blocks with CodeRay to add syntax highlighting. This is what I have so far:
class Post < ActiveRecord::Base
  before_save :render_body
  def render_body
    self.rendered_bo...
            
           
          
            
            Does rails provide solution to get website user time and timezone configured on his local machine, which is used in his web browser?
...
            
           
          
            
            With the Rails text_field_tag --- how do you set an option for the tabindex? 
Thanks
...
            
           
          
            
            I am having to explicitly render :layout => 'application' in my controller actions in order to get my new rails 3 app to actually use the application.html.erb layout file.
Any obvious things to look for that I am doing wrong?  If I don't call the :layout option it just doesn't render the layout.  I get a message like:
Processing by Foo...
            
           
          
            
            I am trying to choose 5 distinct brands from among the cars that belong to my users. My current attempt is below (no approach to selecting at random).
@range = @user.cars.select('DISTINCT brand_id').limit(5)
How might I select these five random distinct brands? Thank you very much.
...
            
           
          
            
            Hey,
Im using rspec and when i run rake spec, the user mailer sends email through smtp and not stores the email in the ActionMailer::Base.deliveries-array (invoked by an user-observer)...
Could you give me a hint why?
# Rails version
rails -v
=> Rails 3.0.1
# Ruby version with rvm (rvm version 1.0.16)
ruby -v
=> ruby 1.9.2p7 (2010-09...
            
           
          
            
            I want to use find_or_create_by, but this statement does NOT work. It does not "find" or "create" with the other attributes.
productproperty = ProductProperty.find_or_create_by_product_id(:product_id => product.id, :property_id => property.id, :value => d[descname])
There seems to be very little, or no, information on the use of dynam...
            
           
          
            
            Hello, I have two models, Product and ProductImage, and I'd like to offer the possibility to add up to 6 images to each product.
Product
has_many :product_images, :dependent => :destroy
while ProductImage
belongs_to :product
So far, my views are the following:
#products/_form.html.erb.
    <% @product.product_images.build %>
    ...
            
           
          
            
            If I attach xls files as attachment in the mailer like this
attachments["1.xls"] = File.read "1.xls"
If I try open the attachment from the received mail, Excel is unable to open and it says the file is corrupted.
Please let me know if I am missing something?
Please let me know if additional information is needed?
...
            
           
          
            
            I am following Ryan Bate's tutorial: http://railscasts.com/episodes/163-self-referential-association
But my setup is slightly different.
I am making comments that are self-referential so that comments can be commented on.
The form displays in the view, but when I submit, I get this :
Routing Error
No route matches "/conversations"
...
            
           
          
            
            I upgraded to RoR 3.0.1 and Ruby to 1.9.2.  Now all the strings in my views are ASCII-8BIT?
I believe I have my app set up to use UTF 8
application.rb
config.encoding = "utf-8"
database.yml
development:
  adapter: mysql
  encoding: utf8
I'm running 
OS X
RVM rvm 1.0.16 
Ruby ruby-1.9.2-p0
Rails 3.0.1
I'd expect that the enodin...
            
           
          
            
            Hello,
I've created:
PhotoAlbum (id, name)
  has_many: photos
Photo (id, name, photo_album_id)
  belongs_to: photo_album
I want to allow a user to upload 1 or more photos. Per Upload whether it be 1 or more photos, they should automatically be added to a new album. 
So the way i have it is, a user clicks upload photos:
They get the ...
            
           
          
            
            I have a helper in my plugin test_plugin/lib/test_helper.rb:
module TestHelper
  def test_render
    render 'test_plugin/test_partial'
  end
end
I have a partial test_plugin/app/views/test_plugin/_test_partial.html.erb:
<p>Hello World!</p>
In my application app/views/tests/index.html.erb when I do this:
<%= test_render %>
I get ...
            
           
          
            
            I'm trying to modify the default behaviour of showing errors before the form to show them next to the fields instead.
I'm using this to achieve that:
  ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| 
      if instance.error_message.kind_of?(Array)
        %(#{html_tag}<span class="validation-error"> 
        ...
            
           
          
            
            So in rails, if any of the input is not valid, the page returns back to the input page and red errors will show up next to that input_text or textarea.
For example, 
<%
    validates_presence_of :email
%>
It will say the error at the top, and the email input text turns into red.
However, when I separately made a valid checking statement...
            
           
          
            
            I'm learning RSpec 2 with Rails 3. In order to set the contents of the  tag in the layout for each page, I have a helper that can be used to set the title and then return it:
def page_title(subtitle=nil)
  if @title.nil?
    @title = ["Site Name"]
  end
  unless subtitle.nil?
    @title << subtitle
  end
  @title.reverse.join " - "
en...
            
           
          
            
            Hello, I have paper_clip installed on my Rails 3 app, and can upload a file - wow that was fun and easy!
Challenge now is, allowing a user to upload multiple objects. 
Whether it be clicking select fileS and being able to select more than one. Or clicking a more button and getting another file upload button.
I can't find any tutorials ...