Sant Davalos
Sant Davalos

Reputation: 39

Why my helpers does not outputting nothing in my view?

I'm new on rails and I have a book to study them. In one practice, I created a helper in my Application Helper, the test from RSpec work fine, until I have to print the result of my helper. No show any result and no error happens.

application_helper.rb

module ApplicationHelper
    def title(*parts)
        unless parts.empty?
            content_for :title do 
                (parts << "Ticketee").join(" - ")
            end
        end
    end
end

show.html.erb

<% title(@project.name) %>

projects_controller.rb

class ProjectsController < ApplicationController
    def show
        @project = Project.find(params[:id])
    end
end

and when I go to the show link I supposed to see "Random Project name - Ticketee", however only they show me "Ticketee".

Any help...

Upvotes: 0

Views: 53

Answers (1)

j-dexx
j-dexx

Reputation: 10406

<% title(@project.name) %>

Means don't show to the user

<%= title(@project.name) %>

Means show to the user - notice the equals.

Upvotes: 2

Related Questions