Hello,
I currently have two workarounds in my rails app :
The first, and I think the most simple : I'm unable to get links for controllers made with script/generate controllers. I made an "index" controllers, and a "news" method in it. I'd like to link_to like : <li><%= link_to 'News', news_index_path %></
but it don't work. What I'm missing here ?
The second : I have a form for players to login. I get a dangerous glitch : it add user in database instead of logging.
Here's the code :
[login.html.erb] <% form_for(@Player) do |f| %> <%= f.error_messages %> <p> <%= f.text_field :name %> </p> <p> <%= f.text_field :password %> </p> <p> <%= f.submit "Login" %> </p> <% end %>
[login in index.html.erb] def login if request.get? session[:current_user]=nil @Player = Player.new else @Player = Player.new(params[:player]) #logged_in_user = @Player.try_to_login if logged_in_user session[:current_user]=logged_in_user else flash[:notice] = "Utilisateur invalide" end end end
[methods in player's model] def self.login (name, password) find(:first, :conditions => ["name = ? and password = ?", name, password]) end
def try_to_loggin Player.login(self.name, self.password) end
Once again, what I'm missing here ?
Any help is apprecied.
Thanks !