Making jQuery and Prototype work together.
I’m sure lot of people must be having this need to use Prototype and jQuery Ajax libraries at the same time. Just by definition they will not like each other. So you have add following to make both of these are happy and do not conflict with each other.
<script>
jQuery.noConflict();
</script>
Thanks to Benjamin Smith and his blog post. Yes he Saved My Day.
Make attachment_fu work with Rails 1.1.6
I was using acts_as_attachment plugin for file upload and I wanted to get the files to Amazon S3. Unfortunately acts_as_attachment does not do that and attachment_fu does (both of these great plugins are written by Rick Olsen) and attchment_fu needs Rails 1.2 and higher. I have a limitation of using Rails 1.1.6. So made attachment_fu work with Rails 1.1.6. Not a whole lot of changes , should take less that 3 mins. So this is what you do
- Depending on what image processor you use (I use RMagick) open the respective image processor file. e.g. rmagick_processor.rb (under /lib/technoweenie/attachment_fu/processors). In self.included(base) method replace following line
base.alias_method_chain :process_attachment, :processing
with
base.send :alias_method, :process_attachment_without_processing, :process_attachment
base.send :alias_method, :process_attachment, :process_attachment_with_processing
(The reason it needed Rails 1.2 in first place because of base.alias_method_chain call which is introduced in Rails 1.2. So It was just a matter of replacing that with the Rails 1.1.6 equivalent). Similarly you can go do the same above change to other 2 processors as well (image_science and mini_magick)
- Next thing (this one is nothing to do with Rails 1.2 issue, this issue was there in acts_as_attachment as well and I have covered that in one of my previous post’s) . open attachment_fu.rb and replace method
def find_or_initialize_thumbnail(file_name_suffix)
respond_to?(:parent_id) ?
thumbnail_class.find_or_initialize_by_thumbnail_and_parent_id(file_name_suffix.to_s, id) :
thumbnail_class.find_or_initialize_by_thumbnail(file_name_suffix.to_s)
end
with
def find_or_initialize_thumbnail(file_name_suffix) respond_to?(:parent_id) ?
thumbnail_class.find_by_thumbnail_and_parent_id(file_name_suffix.to_s, id) ||
thumbnail_class.new(:thumbnail=>file_name_suffix.to_s, :parent_id=>id) :
thumbnail_class.new(:thumbnail=>file_name_suffix.to_s)
end
Thats it you should be flyig with this change on Rails 1.1.6.
Screen name trick in Rails routes
You must have seen http://twitter.com/legalizenet where legalizenet is my screen name and I get a first context on twitter.com like every user. Its just one line of definition in the Rails routes.rb file. Just add following map.connect ‘:screen_name’, :controller => “<somecontroller>”, :action=> “<someaction>”(Note: replace <somecontroller> with right controller name and <someaction> with a right action in that controller)e.g it might look like map.connect ‘:screen_name’, :controller => “profile”, :action=> “home”This will tell rails engine , whenever there is a url like http://<hostname>/<screen_name> send request to profile_controller.rb’s “home” action. and then in home action method just do followingparams[:screen_name] and process it accordingly.Sweet isn’t it?
MessageDance: So it starts.
We have been working on MessageDance for couple of months writing prototype , building blocks and testing the basic end to end promise to see how it works within ourselves. It is a very interesting idea and right now we are on our way to execute this for next cycle which would be public beta.
MessageDance is started by 3 founders (including myself) and we all working full time on this. Work is in full swing from Product Management, Operations, Engineering and Architecture perspective. We recently moved to PlugAndPlayTechCenter. Its a great incubation for emerging technology startups. Energy of this place is very positive and encouraging.
I will have a lot to share here as we progress in our plan but for now we are dancing our way to the next interesting thing in social media.
You can read day to day update on MessageDance Blog and stay tuned to our progress.
You can become one of the first to access MessageDance’s service by signing up with us. Once we are ready for public beta you will be the first one to hear from us.