migueloop
migueloop

Reputation: 541

RoR controller method order affects?

I've dealing with an issue for some days. The thing is that I had a controller with:

private 
def posts_params
    params.require(:project).permit(:title,:shortDesc,:longDesc,:imgName)
end
def show
    @project = Project.find(params[:id])
end

Show method didn't work till I changed the order and I put the private method at the bottom.

Is there any ruby or rails issue related with?

I'm new in RoR

Thanks in advance guys.

Upvotes: 0

Views: 34

Answers (1)

Aguardientico
Aguardientico

Reputation: 7779

all methods before private are private so they can't be call from another class. you can:

  1. change methods order (what you do) or
  2. put public before def show to change the scope.

Upvotes: 2

Related Questions