doug
doug

Reputation: 2111

rails view not rendering

View:

<% form_tag(:action => 'create', :multipart => true) do %>
  Select CSV File:
  <%= file_field_tag 'data' %>
  <br/><br/>
  <%= submit_tag 'Upload' %>
<% end %>

Controller:

class UploadController < ApplicationController
  def index
    respond_to do |format|
      format.html {render :layout => false}
    end
  end

  def create
    DataFile.save(params[:data])
    respond_to do |format|
      render :text => "File has been uploaded"
      # format.html { redirect_to :back }
    end
  end
end

When I go to upload/new nothing is rendered - just a blank page. If I put content in the view outside of the form_tag then it is rendered correctly.

Upvotes: 0

Views: 1211

Answers (1)

Tom L
Tom L

Reputation: 3409

In ERB in Rails 3, use an equals sign to output the contents of a block:

<%= form_tag :stuff do |f| %>
  ...
<% end %>

Upvotes: 1

Related Questions