NoMethodError in UsersController#show

So I am getting the error

NoMethodError in UsersController#show error
undefined method `feed’ for nil:NilClass

{“authenticity_token”=>“zalkdfsjfksjd;lfs;lfksdkf/2tPzo=”,
“login”=>“session”,
“password”=>“admin”,
“commit”=>“Log in”}

Why is login being set to “session”? Instead of the real login?

This is my form:

<% form_tag session_path do %>

Login <%= text_field_tag 'login' %>

        <p><label class="block" for="password">Password</label>
        <%= password_field_tag 'password' %></p>

        <!-- Comment this if you don't want this functionality -->
        <p><label for="remember_me">Remember me:</label>
        <%= check_box_tag 'remember_me' %></p>

        <p><%= submit_tag 'Log in', :class => "btn", :id =>

“login_btn” %> <%= link_to “Sign Up”, new_user_path %>


<% end %>

Here are the relevant controllers and models:
Users_Controller:
def show
#@user = User.find(params[:id])
@user = User.find_by_login(params[:login])
#@feed_items = @user.feed
@feed_items = @user.feed
end

Users Model:
def feed
#Post.all(:conditions => [“user_id = ?”, id])
Post.from_users_subscribed_by(self)
end

Post Model (using SQLite3) :
named_scope :from_users_subscribed_by, lambda { |user|
subscribed_by(user) }

private

# Return an SQL condition for users followed by the given user.
# We include the user's own id as well.
def self.subscribed_by(user)
  subscribed_ids = %(SELECT subscribed_id FROM subscriptions

WHERE subscriber_id = :user_id)
{ :conditions => [“user_id IN (#{subscribed_ids}) OR user_id =
:user_id”,
{ :user_id => user }] }
end

Ok, so I found the issue. The below resource in my routes is the issue.

map.profile_link ‘/:login’, :controller => ‘users’, :action => ‘show’

I used this to try and get Twitter-like urls so something like
myapp.com/coolusername.

So what was happening anything after myapp.com/ was being set at the
:login so I am not sure how to get the Twitter-like urls plus have
things like myapp.com/posts or myapp.com/session.

Anyone have any clues?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs