Ruby on Rails and Datatables.net - ruby-on-rails

Pretty new to the RoR environment and have been trying to incorporate datatables.net into my project located at here
I know where to add the css along with the cdn which is the route I'm taking but the last step for 'Initialising DataTables' and the javascript? that is has there, where would this go in ruby on rails? Spent a lot of time searching google for the answer to get a variety of solutions that didn't work and figured it was time to ask the wonderful experts here.

Finally figured out the problem. Was a simple issue where the scripts where in the body and fixing them into the head section corrected the whole thing.

Related

Auto code grading system like codecademy's

I'm building a ruby on rails application with most of the views with react. I'm considering using CodeMirror as an editor for users to type in code. I want them to be able to submit the code, and the code will be run through some of my test cases and get results back, similar to how codecademy works.
What are some initial steps to achieve this?
Thank you!
Have a look at the http://reactrb.org site. There is live code editors on there. Source code for the doc site is on github.
If the code examples are in either ruby or JS you can run the test scripts in the browser (for ruby you will use opal-rspec) This makes sandboxing easy.
Sounds like a great project. If you need additional questions or help stop in at https://gitter.im/zetachang/react.rb There are a couple of people there who can help you out with the details.

Understanding Application.routes.draw source code

A couple of months ago I started developing web apps with Rails. As with any new framework I use, as a step to further understanding it I’ve started to read the source code. Maybe it’s my relative recent learning of Ruby, but I’m having some troubles making sense of it.
Today I decided to look into Application.routes.draw (from routes.rb) and from the ActionDispatch::Routing documentation I found the draw method defined in rails/actionpack/lib/action_dispatch/routing/route_set.rb but I fail to see where in Application.rb (or Engine.rb or Railtie.rb) it comes into play. Additionally I don’t see where the routes method in Application is defined.
Any answer or link greatly appreciated. Thanks in advance.
Ok, I finally found the routes method in engine.rb, line #488. I’ll take it from there.

Paperclip + Valums ajax file upload plugin for Rails 2.0.2 and Ruby 1.8.7 Config

I am trying to implement ajax file upload using Valums file uploader plugin( https://github.com/valums/file-uploader ), paperclip is doing the image processing for me and helping me in cropping it.
I know many you out there would wonder why I am using this config of Rails 2.0.2.. its mainly for project specific purposes..
I am still a newbie with just around 5 months of experience in Rails..
The overall objective I am trying to meet by using this plugin is to get ajax file upload + ajax display working for me.
Firstly I am trying to make sure that the image which is passed as a parameter and the appropriate processing takes place so that the image is saved in the DB.
The main challenge here for me at least is combining Rails(paperclip.. being the major part of it) + Valums file uploader .
With the help of different search queries in Google, I have finally found something that could really help my case:-
This( http://mooooooooooo.wordpress.com/2010/12/03/paperclip-valums%E2%80%99s-file-uploader-and-middleware-continued/ ) is a blog which pretty much does just what I want it to do..
If you can spare some time reading this blog , you would find that the bloggers ("moortens")
approach is to make use of middleware and invoke the same through initializers..
I am pretty sure this blog is written some time after Rails 2.3.x came into existence.. and since I am still a newbie (please bear with me being a novice) and would have to make similar changes for my dev env which is Rails 2.0.2.. I am kinda lost.. figuring out how would I have to call the "raw_file_upload.rb" for me to get things working...
Kindly help me on this..
Thank you very much..

Well built rails code for download

I want to get into rails by examining well built code
where can i find typical open source rails project that i can download
and learn from ?
i'm interested in facebook connect integration (facebooker), tag clouds, searching in
my website
I'm not looking not tutorials or screen casts
Thanks!
This question gives a good list
a list of projects with good test-suites
a list of open source rails apps to learn from
Have a browse of ruby tool box and download some open source. For example there's refinery and zena, two content management systems and Rboard, a forum. Depends what you want really but there's plenty out there. Ruby toolbox entries are ordered by github watchers and forks to give you an idea of their popularity.
I really like looking at the commits in teambox.
I find it a bit more complicated. But there's also spree.
There's also devise which is really interesting to look at too.
Finally, I'd recommend you to follow the rails commits (it's the only commits feed I have in my Google Reader).
Gady, this is an extremely rich topic you're asking about and resources are all over the internet. Try starting at http://rubyonrails.org/.
You should be able to find tens of questions just like yours (asked and answered) by searching SO at the top bar.
For Rails, part of it is the building process, so one feasible approach is to read a tutorial like http://railstutorial.org/book
then when in Chapter 2, you will use Scaffold, and at that time, you will have some basic code to look into how a basic Rails app is.
I also suggest you use source control like Git, Mercurial, or SVN to commit different phases of the project, from creating the rails project and then after each step, so you can diff what the changes are during each step.
If you already have Ruby 1.9.2, Rails 3.0.1, and sqlite3, then you can
rails new myproj
cd myproj
rails generate scaffold foo name:string salary:integer gpa:float note:text
rake db:migrate
rails server
and now you can use http://localhost:3000/foos to create, display, update, delete the foo records, and have quite a bit of source code to look at. Most of the customizable code is in app, with css and javascript in the public folder.
Ryan Bates has an excellent series of videos.
http://railscasts.com/
An extremely valuable resource.
Radiant is a CMS that you can download for free and see how it works. It is a great piece of code to look at and see how it works.
I guess that most open source Rails projects are shared on Github, so it may be interesting to browse its Ruby section and look for most watched or most forked projects:
http://github.com/languages/Ruby
Steady stream of new interesting projects to take a look at :)
And don't forget the official:
guides.rubyonrails.org
well there is one "bigger" project on github, waiting for downloading and contribution...
but it's a little controversial because of the security issued they have (had?)
It's still worth a look:
http://github.com/diaspora/diaspora

acts_as_ferret multi model search not working in rails app

I am trying to solve a strange issue with ferret/acts_as_ferret
Of course I have googled and posted the question:
http://www.ruby-forum.com/topic/188570
Basically aaf works on single models with no issue. It also works on single models using the config/aaf.rb file I have setup. It even works when I do a multi-model search in the console, but within the rails app itself I get:
undefined method `ferret_rank=' for <object that has a match>
If anyone has had the same experience/problem and can shed any light I would appreciate it.
PS: I followed the following tutorial to get where I am now.
http://opensoul.org/2008/4/29/using-shared-indexes-with-acts_as_ferret
Do you have the plugin installed or just the gem? You might want to install the plugin.
I would also try rebuilding the index.
For my purposes, I switched to Solr and life is a lot easier. Sphinx is missing a lot of stuff that I need.

Resources