Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Andrew Stelmach
12,583 PointsController redirect_back_or_to using the Sorcery gem?
To save myself the trouble of reposting it all here, I'll just post the Stack Exchange link:
http://stackoverflow.com/questions/28586376/sorcery-gem-how-to-use-the-redirect-or-back-to-method
I hope someone can help me with this (I'm sure Maciej will have something to say! ;-) )

Maciej Czuchnowski
36,441 PointsOK, wait, it's on a branch?

Andrew Stelmach
12,583 PointsYes, it's the create_testimonials branch.
I didn't use Devise, because I thought it was superfluous to my needs! I still think I'll be ok with Sorcery; it can even do mailers, but it'll be a bummer if it turns out to be a bad decision.
3 Answers

Andrew Stelmach
12,583 PointsSolved. For anyone who's curious, you can see the explanation in the original stack overflow link.

Maciej Czuchnowski
36,441 PointsCheck out my pull request. Seems it fixed your problem. Let me know if it's still not working properly.

Andrew Stelmach
12,583 PointsThanks for the bonus fix! ;-) (fixing the problem of being able to edit other people's testimonials by changing the address in the browser manually).
def correct_user
if @testimonial.user !=current_user
redirect_to root_path
end
end
This was one of those times when I saw the fix and groaned and thought, "I should have spotted that". What I'd done was to initially follow an example from another app, which didn't work. If I'd stopped to think about it on my own to begin with, I might have come up with this quite obvious fix myself. Thanks!
(I'm going to talk about the other stuff when I've finished going through it)

Andrew Stelmach
12,583 PointsOk, I didn't actually merge your pull, because I haven't done that before, but I DID apply all of your changes manually, except for the apparent change to one of the migration files (except you didn't actually change it??) Anyway, probably not important.
Anyway, I experimented with applying the changes, but it didn't work. But see my notes on the pull request for the strange thing I discovered.
Thanks for all your help so far! Much appreciated!
https://github.com/Yorkshireman/pamplona_english_teacher2/pull/1

Maciej Czuchnowski
36,441 PointsI deleted one of the migration files, because it was in the wrong order (adds a column to a table that does not exist yet when migrated) and when moved to the end of migrations, it adds a field that already exists. Try downloading your project and running rake db:migrate on it and you'll see.

Andrew Stelmach
12,583 PointsOk, I've deleted that thanks
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsAndrew, I downloaded and deployed your site locally, but it doesn't have the button you mentioned and does not have any controllers, so I'm not sure where to even start.