Hello I am having difficulties understanding why the parameter is not passing to the view.
controller
class UsersController < ApplicationController
include UsersHelper
before_filter :set_user, :set_categories
def show
@test = get_test()
end
end
helper
module UsersHelper
def get_test()
puts "hello world"
end
end
view
test: <%= @test %>
What is being displayed test:
Can someone please give me some assistance of why hello world
is not being displayed? Thanks!
--Edit-- It seems like I am not able to even pass any variable messages to the view I added...
controller
@message = "How are you"
view
<p><%= @message %></p>
And How are you
is not displaying.
In your get_test
function, you are printing a string instead of returning the string. To return a string:
module UsersHelper
def get_test()
"hello world"
end
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.