Porting plugins to Redmine 3¶
Query interface changes¶
In Rails 4 queries get built using chained method calls. In Rails 3 you used hashes.
- Use
joins()
instead of:include
. - Use
where()
instead of:conditions
. - Use
order()
instead of:order
. - And so on.
Also, .find(:all)
should be replaced with just .all()
and .find_all_by_*
should be replaced with .where()
.
Observers were removed¶
All things, you did before using observers, now should be done directly in models, e.g., by monkey-patching them.
^ and $ in regexps¶
The system does not allow ^
and $
in regular expressions any longer - you should replace them with \A
and \z
correspondingly.
Attributes assignment protection¶
In Rails 4 you have to use either attr_accessible
or attr_protected
(seems to be preferred by Redmine guys) to white-list or black-list attributes for mass assignment.
Otherwise you are going to get: WARNING: Can't mass-assign protected attributes for YourModelClass: attribute1, attribute2
Update should use PATCH now¶
Rails guys decided, that the PATCH
HTTP method sounds better for update, so everyone is now forced to switch from PUT
to PATCH
.
Certainly, you could modify the code to still use PUT
, but I would not go this way (as it’s going to be non-standard since Rails 4)...