Ruby on Rails - Having issue when generating a page - ruby-on-rails

when I try to run the server after creating a home/index page i get the following error. I wonder if you can help me.
Error: Cannot find module './templates.js'
Require stack:
C:\railsfriends\friends\node_modules\chalk\index.js

You have an error from the chalk javascript library, which can't find its expected template.js file. Try removing chalk from your package.json or wherever it's being loaded, so you can get the basic app working and then add it later, and debug the module then.
A 'nuclear' option (which is pretty safe on a new project, especially if you haven't touched the Javascript components yet) is to delete your node_modules directory from the project and then to run yarn install from a terminal in the project directory - this will read the required JS packages and install them again for you.
Not hugely helpful about the specific issue, I know, but the error message you posted tells you what the problem is, and it doesn't seem to be Rails itself. You may have more luck adding a tag for js and chalk specifically, to attract readers with that specific knowledge.

Related

Issue with Rails Generator Building a Plugin

I am building a Rails plugin for an application at work.
I want to extract logic that was used in multiple locations, but implemented slightly differently, and add new features needed without doing it 2-3 times over.
I've never build a gem, but according to what I was reading it is possible to use rails generate.
However this has not been the case for me.
Running rails g model Something stuff:type:
First interesting thing is that it is generating mini test stuff when I explicitly told the plugin not to use mini test (using Rspec).
Then looking in my folder structure for the plugin, no db/ folder, nothing added to app/models/, and no test/ folder:
Running the command a second time reveals to me that the files are indeed created:
My questions are:
Where is this stuff going? Can I even find out?
Has anyone encountered something similar? Is it due to a misconfiguration, or bug? Essentially, what's happening?
I would truly appreciate any advice or suggestions!
EDIT #1
Forgot to mention that I checked within the spec/dummy application in case things were being created there, and it is still empty as I left it.
EDIT #2
So I found where the files were by using the find command:
And yeah it added the files to my home folder...
At least now I can just paste them in the right location, but obviously this is bizarre and I'd like to get this resolved, figure out what is going on.
Okay so turns out that yes you may use Rails Generators when building a gem. Also, the generated files will not be placed inside the dummy application unless you are in that directory.
Everything is working as expected on a different computer.
That stuff is going into dummy app that is usually located in test/dummy. In your case, it seems to be located in specs/dummy.
Yeap and nope. That's not misconfiguration.

rails react browserify TypeError: Object function has no method 'extend'

I'm trying to make a web app using rails, react, and browserify. I've been following this tutorial, and since I want server-side rendering, I've used this repo as a starting point, and followed the tutorial mentioned in the README file.
Although I think I've done things as the mentioned articles suggest, I cant figure out how to solve the following error:
TypeError: Object function ( w ) {
if ( !w.document ) {
throw new Error( "jQuery requires a window with a document" );
}
return factory( w );
} has no method 'extend'
If you want to reproduce the error, clone my repo, which is opensource and its on github, and go to the feature branch auth, instal the gems and npm packages and lift the server:
$ cd path_to_project
$ git checkout -b feature/auth
$ bundle
$ npm install
$ bundle exec rails server
I would really appreciate any help, since i'm currently stuck here. Also, I'm new to react, so I don't know pretty much where to look for the problem.
EDIT: By request in the comments, I've removed the stacktrace in order to make the question more readable. If you need any extra information, please let me know.
I happened to be using the j-toker CommonJS package which internally uses jQuery's ajax API. jQuery is incompatible with server side rendering since it needs a document element to load itself, and it only exists in the browser, not in the server. The solution is not yet at hand, but as J-Toker's author has indicated, he's about to release a new library that covers the case of server side rendering.
So, to anyone encountering a similar error, check if you are using jquery or any other package that in turns depends on jquery, or requires having a document DOM element, and try using a server-side-rendering-safe alternative.

Add ng-Table ao Meanjs

I'm trying to add a third module for use.
The module is the ng-table.
When I add the module in applicationModuleVendorDependencies returned one dependency injection error.
Am I not doing the right thing?
Someone has already implemented the ngTable using the yeoman generator MEANJS?
Seeing the code would have been the best thing so that I can get to know what you exactly doing wrong or forgot to do, but I think either one or more of the following could be the cause
you forgot to include it in your lib files in the config > env > development.js
the library is not install yet
or just a small typo somewhere
but I strongly suspect it would be the first point, as I have used it before, and worked just fine with meanJS

Orchard CMS Speed Issues

I'm setting up an Orchard CMS site and noticing that it is incredibly slow.
It is running on a VPS that hosts a couple of other MVC based websites which all run fine, so the server doesn't appear to be the issue.
I've read that renaming the Sample.Host.Config file to Host.Config should fix the issue. Which it seems to do for a few hours, until randomly I then get the following error and the site no longer works.
The type 'Orchard.Environment.Configuration.AzureBlobTenantManager' could not be found. It may require assembly qualification, e.g. "MyType, MyAssembly".
I've tried installing the Cache module which hasn't made any difference.
Has anyone else experienced slowness with Orchard CMS? This is a brand new installation with no extra modules and no content... I'm stumped!
Any help is much appreciated
Here are a few things you can try:
As you did, renaming the config file. You need to make sure you are running a prebuilt version.
Installing the Cache module, as you did. This is going to be bundled into Core, it is essential.
Installing the SysCache module to cache database calls
Install the Warmup Module which saves static versions of your pages to serve to the user
Turn off debug flag in Web.config (just in case... ^_^)
Use SQL Server for the speeeeeed
Make sure you have selected the same region for database etc.
To the specific error you are receiving, I also had that error a while back but this was due to my package not being fully built. So why yours would run for a while then break is a mystery... Did you maybe install some modules or something?
Enable the SysCache module in the "Performance" section of Modules
I would also disable the dynamic module loader, stated here towards the middle of the page: http://docs.orchardproject.net/Documentation/Orchard-module-loader-and-dynamic-compilation

Rails SequencedHash source file

I am testing AlumniOnRails (http://rubyforge.org/frs/?group_id=2959&release_id=17170) which is based on Rails 1.2.6 (I know it's outdated) and managed to get it up, installed the required gems, created and migrated the data and most of the basic alumni functionalities are up but one, the part that is broken seems to be missing a library and yet I can't seem to find it after a few reasonable searches.
The logger shows no such file to load -- collections/sequenced_hash with a line within the controller having the code of require 'collections/sequenced_hash which is quite obvious that the sequence_hash library is missing.
A few searches on Google shows a few references, one with the closest pointer is http://collections.rubyforge.org/classes/SequencedHash.html but unfortuntely the source link is dead. Does anyone keep this kind of old file or point me to somewhere it is? Thank you
Somebody answered this over ruby forum and it works:
gem install collections

Resources