Ariff Munshi

Joined

11,280 Experience
99 Lessons Completed
1 Question Solved

Activity

Posted in Sending emails with Mandrill Discussion

Thanks for the update @excid3:disqus! Yea.. wanted notify anyone else looking at this tutorial that Mandrill is a paid service after today's announcement. Perhaps a tutorial on how to set up with Amazon SES or just Gmail if the load is not heavy..? :)

Posted in Upload Progress with Refile Javascript Discussion

Not my code but you can take a look at this:
http://jsbin.com/uboqu3/1/e...

Posted in Upload Progress with Refile Javascript Discussion

Hey @szilardmagyar:disqus I did not implement a solution. For one of my apps I was still using the older version of refile and only admin are allowed to upload images. So there was no issue about the security bug.

As for my other app, I just did not implement the preview feature as I felt that it was not critical at this current moment. Will revisit the issue when I have the time. Nonetheless, I think a simple solution is to write your own javascript to show the image directly from your file system and not use Refile. So just add an image tag with the source as the file path of the image and load/show it using javascript. Doing a round trip to the servers will defeat the purpose as it will still only work after the image has been uploaded.

Hope this helps.

Thanks it works! Just had to edit some of the previous js code.

p.s. any plans for a yearly subscription plan?

Thanks for the note Chris! Your replies alone are worth the subscription to GoRails.

Anyway never heard of the gem but I'm sure it will come it pretty handy. Will give it a try tomorrow and let you know it it works.

Hey Chris,

Just watched and implemented the code from this screencast and it's working well. However, I realised that it only works on first page load. Subsequent pages do not run the function. Not sure if there's a bug in my code or it's because of turbolinks. Im not using bootstrap but my own implementation of an off-canvas notification (like in Macbooks).

I call all my functions in Application.js. My attempts to call the Notifications function on page change gives: "Uncaught ReferenceError: Notifications is not defined"

I'm not too versed in CoffeeScript and especially not with using classes. How do I call the Notifications function on page:change?

Cheers,
Ariff

Posted in Upload Progress with Refile Javascript Discussion

@excid3:disqus yea it seems that's it's not currently possible to do so.
https://github.com/refile/r...

Posted in Upload Progress with Refile Javascript Discussion

Seems like the solution to show a preview image will not work any longer the latest version of refile. Even with Olivier 's suggestion to get the image id using the below code will not work as you will get a 403 (forbidden error).

image_info = $("input[name='user[image]']").val()
image_id = JSON.parse(image_info).id

Urls for version 0.6+ are signed with a token. Hence the new url will be:

imageUrl = '/attachments/' + token + '/cache/fill/360/360/' + imageId + '/image'

Will update this post if I find a way to do this. Or if anyone else has a solution, please do share.

Thanks Chris! Yea spent a whole day trying to figure it out. Most answers were for capistrano 2. Tried installing capistrano rails console and still nothing. Hope it helps anyone facing the same problem. Maybe I'll post a comment on the deployment guide to share this tip.

Ok got it to work. Had to remove bin from set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}.
This is for capistrano 3.

Hi, sorry to bring this topic up again after almost a year. I did as the tutorial showed by Chris to set up a digital ocean vps on Ubunto 14.04 with passenger phusion, nginx and capistrano. However, I am not able to access the the rails console when on my virtual machine. The command above doesn't work for me. It shows..

Usage: rails new APP_PATH [options]

I even tried installing capistrano-rails-console gem but it still show the same error message.

To add, the app works fine after I deployed it last night. It would be great if I could get into console to add some records.

Ok got it Chris. Time to look into writing cron jobs then! Thanks.

Hi all, I posted this question on Stack Overflow for a problem I am stuck at.

http://stackoverflow.com/questions/30805987/using-scopes-to-order-users-with-most-votes-for-specific-time-periods

I have User model that has_many Posts that has_many Votes. I have figured how to rank users by the total number of votes they have received using scopes and the counter_culture gem to sort the total_votes_count.

The problem here is now I would like to rank them based on time periods like today, this week, this month. For this I have to total only the votes casted within those time periods. I can write scopes for the votes for these time periods like for example:
Bumps.where('created_at > ?' 1.week.ago).count

How do I pass this to total for all the post then for every user and to sort them eventually?

Any help would be great. If it really is a tough one, I'd consider to just putting the time filter on posts created_at and rank based and the total votes then order the users based on that. Need to figure out how to do that as well.

Cheers!

Posted in Problem with upgrading to Rails 4.2.2

oh man! @James you're right. I think I must have got mixed up with the version.. installing too many things today. Yup it should be 4.2.1 and not 4.2.2. Just checked the setup guide and 4.2.1 is recommended. Wonder how I saw 4.2.2.

All is good now. Thanks for all the input guys!

Posted in Problem with upgrading to Rails 4.2.2

Hey Siddharth thanks for the reply.

Yea tried that already but it comes up with this error:

ERROR: While executing gem ... (Errno::EACCES)
Permission denied @ rb_sysopen - /Users/ariffmunshi/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rails-4.2.1/README.md

Posted in Problem with upgrading to Rails 4.2.2

Hi all,

Hope that someone here can help. I just got an old mac back and bumped it up to OSX 10.10.3 (was on snow leopard). Did a whole reinstall for homebrew, rbenv (was rvm), ruby (2.2.2), rails (4.2.2), postgres etc following the guide on "Setup Rails".

Was trying to get back to revive a project neglected for over a month which was on rails 2.4.0. The problem is trying to update the rails version to 4.2.2. The gemfile.lock won't let me upgrade by bundle install and bundle upgrade rails keeps throwing this error:

Could not find gem 'rails (= 4.2.2) ruby' in any of the gem sources listed in your Gemfile or installed on this machine.

Tried un update to 4.2.1 and it worked perfect. Any ideas how can I work around this? Would it be ok the directly edit the gemfile.lock?

Thanks in advance.

Cheers,
Ariff

Posted in Liking Posts Discussion

Thank Chris. Yea I think I'll have to go with the second option. Still trying to master working if JS in rails though.

Posted in Liking Posts Discussion

Hey Chris,

How do I make the before_action :authenticate_user! to work with ajax? If works perfectly, when there is no remote: true and redirects to the login page if a user is not signed in. However, when using ajax, nothing happens other than a "401 unauthorized" in the logs.

Thanks in advance.

Posted in Liking Posts Discussion

This is awesome! Just the functionality I need. Was looking at the "Act-as-votable-gem" but that seems to be overkill as I only need upvotes. Just need to figure out how the gem does the counter caching stuff now

https://github.com/ryanto/a...

I just saw this in a comment for the top answer (link at the bottom):

"DON'T FORGET THE ID!!!! pets_attributes: [:id, :name, :category] Otherwise, when you edit, each pet will get created again"

Perhaps this is why. Didn't manage to test it as I'm not enabling edits for my app.

http://stackoverflow.com/qu...