I'm try to develop redmine plugin which have some forms about dates. When I try to configure route settings, rails showed me this error. I couldn't fix it. Where is the problem?
I got this error:
/days/new.html.erb:20: syntax error, unexpected tLABEL, expecting keyword_end ...ppend= form_for(@daysoff) url: {action: "create"} do |f| @o... ... ^ /var/www/redmine/plugins/days_off_redmine/app/views/days/new.html.erb:20: syntax error, unexpected keyword_do_block, expecting keyword_end ...off) url: {action: "create"} do |f| @output_buffer.safe_appe... ... ^ /var/www/redmine/plugins/days_off_redmine/app/views/days/new.html.erb:44: syntax error, unexpected keyword_ensure, expecting end-of-input
config/routes.rb
get 'days_off_redmine', :to => 'days#index'
get 'days_off_redmine/new', :to => 'days#new'
post 'days_off_redmine', :to => 'days#create'
model/daysoff.rb
class Daysoff < ActiveRecord::Base
unloadable
end
days_controller.rb
class DaysController < ApplicationController
unloadable
def index
end
def new
@people = User.all
@user = User.current
@daysoff = Daysoff.new
end
def create
end
end
days/index.html.erb
<%= link_to 'New', days_off_redmine_new_path %>
days/new.html.erb
<%= form_for(@daysoff) url: {action: "create"} do |f| %>
<%= f.date_field :date, id: 'altField' %>
<%= f.select_field "user", options_from_collection_for_select(@people, "id", "name"), prompt: "Select user" %>
<%= f.submit "Submit" %>
<% end %>
Extra Question: Actually I don't need extra page, how can post my form in the index controller?
Change your form to this:
Just instantiate @daysoff and @people variables inside index action and you are good to go.