Reputation: 1902
I am trying to render a template by clicking on a link .
Here is what I am doing :-
link_to "Profile", render :template => "profile"
This gives me an error:-
SyntaxError in Settings#account_setting
Here is my settings controller :-
class SettingsController < ApplicationController
before_filter :authenticate_user!
def profile
@user = current_user
request.method.inspect
if request.method == "POST"
@user.update_attributes(params[:user])
flash[:notice] = "You updated your profile successfully."
end
end
def account_setting
end
end
This is the error :-
syntax error, unexpected tSYMBEG, expecting keyword_do or '{' or '(' on this line %li=link_to"profile", render :template => "profile"
This is the generated markup of the error :-
syntax error, unexpected tSYMBEG, expecting keyword_do or '{' or '(' ...se((link_to("profile", render :template => "profile"
What could be the issue?
Upvotes: 0
Views: 742
Reputation: 230346
You are doing it wrong.
= link_to 'Profile', @profile
This will generate something similar to
<a href="/profiles/1">Profile</a>
upon clicking which ProfilesController#show will be called and corresponding view rendered.
You can, of course, fire an ajax query here, fetch rendered template and display it dynamically, but I think, it's too early for you now.
Upvotes: 0