Syntax error, Unexpected keyword_end, expecting end-of-input

Asked

Viewed 1,745 times

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

1 answer

4


The first word of your code is Class. I suppose it should just be class.

So you have one end additional in your code, which should be closing the class. just fix the capitalization.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.