3
I’m in a lot of trouble (It may be ridiculous thing but I don’t know what to do anymore). The following error is appearing:
Syntaxerror in Group::Groupsuserscontroller#create /home/Bruno/documentos/sites/mymoney/app/controllers/group/groupsusers_controller.Rb:38: syntax error, Unexpected keyword_end, expecting end-of-input
But so far I haven’t been able to figure out where that bloody 'end'.
Follow the codes:
Class Groups::GroupsusersController < ApplicationController
before_filter :require_authentication
def create
#goupsuser = group.groupsuser.find_or_initialize_by(user_id: current_user.id)
#groupsuser.update!(groupsuser_params)
#head :ok
@groupsuser = Groupsuser.new(groupsuser_params)
if @groupsuser.save
flash[:notice] = 'User was successfully add.'
else
flash[:notice] = 'User cannot be add.'
end
end
def new
@groupsuser = Groupsuser.new
end
def update
create
end
private
def group
@group ||= Group.find(params[:group_id])
end
def user
@user ||= User.find(params[:user_id])
end
def groupsuser_params
params.require(:groupsuser).permit(:user, :group)
end
end
The presenter:
class GroupPresenter
delegate :user, :name, :created_at, :to_param, to: :@group
def self.model_name
Group.model_name
end
def initialize(group, context)
@group = group
@context = context
@groupsuser = groupsuser
end
def can_invite?
@group.user == @context.current_user
end
def groupsuser
@groupsuser = Groupsuser.new
end
def groupsuser_route
[@group, groupsuser]
end
def to_partial_path
'group'
end
end
The form:
<% if group.groupsuser.errors.any? %>
<div id="error_explanation">
<%= t 'general.form_error' %>
</div>
<% end %>
<% if group.can_invite? %>
<%= form_for group.groupsuser_route do |f| %>
<%= select("group.groupsuser", "user_id", User.all.collect {|u| [ u.full_name, u.id ] }, { include_blank: true }) %>
<%= f.submit 'Add' %>
<% end %>
<% end %>
The model:
class Groupsuser < ActiveRecord::Base
belongs_to :user
belongs_to :group
end