← Back to Upcase

Unable to find error to get app to work after moving code into module

(Jacqueline Homan) #1

And the file uploader for this forum isn’t working for me, either so I can’t even upload my screenshot of the error. (This pertains to Part 3 at the end where Matt moves code into a Module). I can’t get it to work for me. Could somebody help me please? Here is the link to my gist file of the code.

(Zachary Davy) #2

I’m not quite sure what the problem is you’re getting, but I think I see a problem.
ActiveSupport::Concerns should be ActiveSupport::Concern, no ‘s’ on the end.

Also, I assume by the title that the you have gistfile1.txt saved as app/models/concerns/following.rb? If not that’s where you would want to save it.

I hope this helps :smiley:

(Jacqueline Homan) #3

Yes, it is saved as app/models/concerns/following.rb. And I did whack off the “s” on ActiveSupport::Concern, but the app still won’t work for me. When I go to logout or click on a user to follow, it won’t work for me. So I am stuck and unable to progress any further in this and time is ticking away on the 3-mo paid subscription that a friend paid for for me as a Xmas gift—to help me as an extremely poor sex trafficking survivor to learn a difficult new skill so I can maybe rebuild what’s left of my stolen life.

(Jacqueline S. Homan) #4

Here is the error I get at the end of Part 3 for the refactoring and adding the concern module:

ArgumentError in HomeController#show

wrong number of arguments (0 for 1)
Rails.root: /home/jacqueline/thoughtbot/shouter

Application Trace | Framework Trace | Full Trace
app/models/dashboard.rb:2:in initialize' app/controllers/home_controller.rb:4:innew’
app/controllers/home_controller.rb:4:in `show’

Here is the lnk to my git repo:

(Zachary Davy) #5

I believe the error is saying that you need to pass params to your new dashboard instance

EDIT: Yeah your Dashboard class requires a user

(Jacqueline S. Homan) #6

I tried that but it still isn’t working CORRECTLY for me. So I took it back out. I tried @dashboard = Dashboard.new(user) and @dashboard = Dashboard.new(@user) and still won’t work right for me.

(Jacqueline S. Homan) #7

OK. I finally was able to get this to work after conferring with my friend and former Rails Girls Summer of Code coach. I tried passing in the params, current_user, as such:

@dashboard = Dashboard.new(current_user)

And now it works! And the reason it works is becuase current_user is what was passed in the dashboards controller; only the current useer would see his/her dashboard. So this makes sense.