Project

General

Profile

Possible error in plugin tutorial?

Added by Harry Garrood almost 13 years ago

I was going through the plugin tutorial, and when I reached the bit:

Edit your PollsController to do so:

1 def index
2 Herve Harster = Project.find(params[:project_id])
3 @polls = Poll.find(:all) # @project.polls
4 end

The project id is available in the :project_id param because of the :param => :project_id option in the menu item declaration above.

I got a RecordNotFound error when clicking on my new button on the project menu.
It worked when I changed line 2 to:

Herve Harster = Project.find_by_identifier(params[:project_id])

Have I done something wrong, or does the wiki need updating?


Replies (7)

RE: Possible error in plugin tutorial? - Added by Mischa The Evil almost 13 years ago

I think the wiki needs updating, but I'm not sure if your change is the correct fix or not. You can edit the page yourself too AFAIK...

RE: Possible error in plugin tutorial? - Added by Harry Garrood almost 13 years ago

Fair enough. I was hesitant to edit it myself, since I'm not sure either.
Could it be that what's there at the moment works in rails 3? (I'm on 2)

Edit: I went ahead and added a little note to the wiki.

Edit: The wiki has been edited again by Etienne Massip - it seems that the correct fix has been applied, this can be closed. (Can threads be closed on here?)

RE: Possible error in plugin tutorial? - Added by Massimo Barbera almost 13 years ago

Dear all,
let me anticipate that I am a perfect newbie with Redmine stuff working with Redmine to 1.3.0

Maybe the change recently applied to the wiki is not 100% correct (or maybe I am doind something wrong)?

The following is the change suggested currently by the wiki

1 def index
2 @project = Project.find_by_id(params[:project_id])
3 @polls = Poll.find(:all) # @project.polls
4 end

with this change, when I select "Polls" I can't see other project menu options.

While if I perform the change that was previously suggested by the wiki (the one at the top of this page) everything works fine with project menu options.

Unfortunatley in this case I have a problem when I click 'yes' or 'no' in the poll as I got the following error:

ActiveRecord::RecordNotFound in PollsController#index
Couldn't find Project without an ID

And... clicking the "BACK" button of the browser the yes/no statistic is correctly updated.

Do you have any suggestion?
Thanks!

RE: Possible error in plugin tutorial? - Added by Harry Garrood almost 13 years ago

On Redmine 1.2, Project.find(params[:project_id]) is now working for me, as is Project.find_by_identifier(params[:project_id]). Project.find_by_id is not, however. I'm quite confused about that. I will change it back to how it was originally. (whoops)

RE: Possible error in plugin tutorial? - Added by Massimo Barbera almost 13 years ago

I see and I understand why you are confused.

Please notice that, as I have stated in my previous post, with Project.find(params[:project_id]) we will have a different issue:


a problem when I click 'yes' or 'no' in the poll as I got the following error:

ActiveRecord::RecordNotFound in PollsController#index 
Couldn't find Project without an ID

And... clicking the "BACK" button of the browser the yes/no statistic is correctly updated.

it looks like a problem related to the redirection only since yes7no counters are correctly updated.

RE: Possible error in plugin tutorial? - Added by Harry Garrood almost 13 years ago

I think that's unrelated.
Have you followed the tutorial exactly up to that bit?
Edit: Also, does your index action correctly find the project? (is the project menu displayed)
Another edit: maybe it would be a good idea to start a new thread for this.

RE: Possible error in plugin tutorial? - Added by Massimo Barbera almost 13 years ago

Yes, I have followed the tutorial up to that bit.

Yes, the project menu is displayed.

I will open a new thread and link this one.

Thanks

Opened new thread "Plugin tutorial - Pools from project menu - error after pressing Yes/No" http://www.redmine.org/boards/3/topics/28324

    (1-7/7)