Rails 4.2 + Ember => unexpected identifier - ruby-on-rails

I'm following Vic Ramon's tutorial. I tried to use the latest version of Rails and Ember-source and I get the following error when visiting home page:
After clicking on link next to error I get this:
How can I fix that?
I ran the following commands:
rails g ember:bootstrap -n App --javascript-engine coffee
rails g ember:install
I removed turbolinks. I also created home controller and an empty view for home#index. Root is set to home#index. Also created following view file:
// app/assets/javascripts/templates/application.js.emblem
h1 Hello World
outlet
Ember gems im using:
Using emblem-source 0.3.18
Using ember-data-source 1.0.0.beta.14.1
Using ember-rails 0.16.1
Using emblem-rails 0.2.2

This could be due to some version incompatibilities between your versions of ember-related gems, as there were quite substantial changes in recent versions of ember (e.g. introduction of HTMLBars, etc.)
Your best bet is to clone the original repo and then try to upgrade individual gems and check if it still works after each upgrade. This way you will be able to identify the troubling gem.
I have verified that the original repo code indeed works with the versions of gems in its current Gemfile.lock.
If you are starting a new Rails + Ember app, ember-cli-rails is probably the way to go, giving you the best of both worlds.

Emblem was the culprit. Replacing .emblem with .handlebars fixed the problem. I tried the tip from emblem-rails git page and icluded
gem "emblem-source", github: "machty/emblem.js"
but that didn't change anything.

I also followed this tutorial (alongside a few others) and I encountered several issues alongside the way ranging from handling templates to setting up the JSON API. I don't see your entire source code so I cannot pinpoint the exact problem. However, it seems that we have similar projects, so you can compare your code to my blog project source code and see what is causing these issues. Comparing to Ramon's tutorial, my blog has implemented everything until chapter 15.
https://github.com/Deovandski/Fakktion/tree/Ember-Rails
If you are a beginner like myself, then I recommend avoiding CoffeeScript and Emblem and sticking to Javascript as much as possible for the first months because you will find more resources and examples. Also, let me know if you need assistance in setting up the project as I used .gitignore to hide things like secrets.yml

Related

How to upgrade Administrate gem

I have a Rails 4 app with Thoughtbot Administrate for the admin part.
Recently I tried to upgrade from version 0.1.2 to 0.1.4, but I got this error: cannot load such file -- administrate/fields/base.
It was triggered from a custom field file, so I tried to run rails g administrate:install, which asked me to overwrite all my administrate controllers and dashboards.
Now, I have made customizations to those files, so I opted not to overwrite them, but then I ended up with the same error as before.
Next, I made another branch to test and let administrate to overwrite my controllers and dashboards, and this time it worked!
So, I think the question is, what is the process to upgrade the gem without losing my customizations?
Is there any task I can run in order to "register" the updated gem, like rake administrate:upgrade or so?
Thanks!
Found out the error.
Seems that administrate/fields/base is now administrate/field/base, so this subtle update in the Administrate gem code is breaking my custom field.
Anyway, I think a potentially breaking update to the gem's code should be advertised and maybe even change the mayor version number, so I'll rise an issue in github for this one.

How to convert a large gem to standalone rails app

I'm building a social network and have been using the gem community_engine but have been having trouble implementing the large amount of customization that I need for my app. I figure this will make it easier for me to override and add methods, as well as help me to better understand and learn from the code since I will be able to actually see all of it in action.
So far in my attempt I downloaded the source code, added the default bin directory and config files that were missing, as well ass all the gem dependencies.
What else do I need to do to get the app to work? I realize that there may still be a lot and that it might not be easy to explain, but at the very least is there any sort of documentation out there that might help me understand how to convert the gem to a Rails application?
Heres the community_engine repo: https://github.com/bborn/communityengine
Because this idea may draw some criticism, I'll add that I was originally building the app without any huge plugins accept for devise however I'm running out of time to finish this.
More stuff I've tried:
Moving files to a new rails app, got server to run but encountered many seemingly random errors, fixed a few but more just seem to pop up that I cant figure out:
I also took a look at http://guides.rubyonrails.org/plugins.html but this gem seems to go beyond that.
I would suggest that you clone the gem and begin copying files from the gem into your a new Rails application.
The engine gem probably has a similar structure to a Rails application, so you should be able to move the files from the corresponding folder to the same folder in your Rails root folder.
You may need to move gem files out of modules, change namespaces etc. Relevant folders to look at files you'll want to include might include app/ config/ db/, any gem dependencies in Gemfile or the gemspec file, as well as spec/ or test/.
Beyond that I think there's no silver bullet answer to your question, you're just going to have to work through problems until you have this up and running, and perhaps ask subsequent questions if you hit on an obstacle that you don't get beyond.
I think what you're looking for is a way to hook your Rails Engine into a rails app. The Hooking Into an Application section of the Getting Started with Rails Engines guide should be exactly what you're looking for.
Here are two additional resources on Rails Engines.
A Guide to Rails Engines in the Wild
Rails::Engine - Ruby on Rails API

How to install latest official refinerycms-calendar 2.0.2 in RefineryCMS 2.1.1

I have been eating my nails the whole weekend to figure out the right combination of modifications to the official refinerycms-calendar in order to make it work with RefineryCMS 2.1.1.
Here are my conclusions and efforts, hoping that someone will drive me to the right direction:
Adding just gem 'refinerycms-calendar', '~>2.0.0'
as suggested in the github page is not working out of the box. You need to correct the dependencies on the .gemspec file. There are many forks out there created only for this correction.
So, I forked the refinery/refinerycms-calendar project, corrected the dependencies and used my fork in the Gemfile.
Backend (BE) works fine: Created an event, went back to FrontEnd (FE), got a "This page is NOT live for viewing"
This frontend (FE) inconcistency is corrected to the BE > Pages > Venues page: /calendar/venues is not an existing route and needs to be corrected to /calendar/events. The seeds.rb needs to be corrected for a permanent solution.
Go back to FE, now the /calendar/events is blank! I only get the title of the Page as defined on the relative Pages page.
A look on the rails server log reveals that there is a :find_page error resulting form the fact that the refinerycms-events.css under the engine's public/stylesheets folder is neither picked up nor referenced correctly inside show.hrml.erb and index.html.erb files. I copied the refinerycms-events.css under vendor/stylesheets and changed the reference to refinerycms-events.css accordingly.
Refreshed FE but still there is a blank page both when getting /calendar/events and /calendar/events/#{event}
NOTE: If I "rake routes" I can see that the routes for the FE portion are repeated 3 times. I am not quite sure for this behavior, but when I substituted "Refinery::Core::Engine.routes.append do".gsub("append","draw"), I could only see them once.
I have tried many forks around and all of those seem to demonstrate the same behavior.
Can anybody please let me know:
a. If you finally managed to have this (official refinery release) engine fully functional in your projects and if yes which branch was used and with which exact Refinerycms and refinerycms-calendar version combination.
b. If used used a fork rather than the official refinerycms-calendar release, then which fork/branch is that.
I hope someone to have that nailed down.
Best regards,
Petros
Well, seems that changing :body_content_left and :body_content_right with :body and :side_body respectively inside the Engine's show and index views, solves the issue of the /calendar/events and /calendar/events/:event FE pages being blank.
I am still unsure why this is causing such an issue and it is kind of weird nobody to have reported it until now.

Rails 2.3.8 tiny mce issue - undefined method `uses_tiny_mce'

I am facing an issue in my application with tiny mce.
All the gem version & ruby version is OK on my system, but it is giving me error
= undefined method `uses_tiny_mce'
Here i installed the tiny_mce gem. COnfigured it correctely, but still there is an issue.
Please help.
Did you include
config.gem 'tiny_mce'
in config/environment.rb?
I have used this gem in the past too, but have stopped using it. I figured it complicated the setup and deployment of my Rails apps. Since then I have just used the TinyMCE editor by itself. Since it is 100% javascript, it does not touch any Ruby code which keeps things better organized.
I was not using this as a plugin.
I have followed the steps given in the,
http://enginey.googlecode.com/svn/trunk/vendor/plugins/tiny_mce/README.rdoc
Steps :
script/plugin install git://github.com/kete/tiny_mce.git
rake tiny_mce:install
my issue got resolved.

rails plugin installation and upgrades

I have a rails plugin written in v 2.1.1. When I install it in a 2.2.2 app, it breaks the app. I'm unable to use polymorphic routes so something like
<%= link_to #object %>
Doesn't work, because it says:
ActionView::TemplateError (undefined method 'polymorphic_path' for #<ActionView::Base:0x1a95c1c>)
If I script/plugin remove the plugin, it's still broken. So I have a two part question:
What is script/plugin install doing besides just copying the files into vender/plugins. From the output after installing it, it just looks like it's copying the files over, but clearly something else is going on behind the scenes, because removing it doesn't fix the problem
What do I need to do to update this plugin for rails 2.2.2. I don't know much about plugins, but I don't see anything that has specific version code in the plugin itself, so I can't figure out what exactly is breaking and what needs to be updated. Obviously this one is kind of tough to answer without seeing the code, but it's not actually the code in the plugin that's breaking, it's the plugin that is affecting my whole rails config.
Does anyone have experience with upgrading plugins to work for newer versions of rails?
Turns out the plugin was overwriting the RouteSet::draw method and just needed to be updated to the 2.2.2 draw code :P

Resources