How to recover app/controllers on Ruby Rails? - file-recovery

I accidentally deleted my app/controllers file on Ruby Rails. How would I get it back? I didn't use git init when I first set it up.
Thanks

You really don't have to start a whole new project if you've permanently lost your controller file. You can do a 'rails g controller ControllerName new index show create etc.'
You'll still have to fill in a lot of the logic, but it's better than starting your whole project over. And for the love of ${DIETY} back up your stuff.

Related

Nelmio/Alice 2.x Symfony 3 , Loading Related Fixtures in Different Bundles

If there's already answer to my question then sorry and please point me in the right direction because I can't find anything.
Let's say I have two Bundles. Each bundle has fixures.yml file and loader file.
Loaders and fixtures are working fine when they are not depending on each other.
However when I am referencing fixtureA from fixtureB I get duplicated record in database.
E.g:
user_{1..10}:
email (unique): '<firstName()>+<randomNumber()>#gmail.com'
plainPassword: 'secret'
story_{1..10}:
user: "#user_<current()>"
title: '<word>'
When they are in separated files - duplicated row. When they are in the same file everything is ok.
Why it's being loaded twice?
I even tried this:
$objects = Fixtures::load(__DIR__ . '/fixtures.yml', $manager, ['persist_once'=>true]);
No luck.
Evey time I am trying to use user object in story fixtures alice tries to save it into db again.
Best Regards,
Robert
I did a little research and talked to people - it looks like it's a possible bug. You can learn more here:
Nelmio/Alice 2.x Duplicated Row
Also I would like to share my work around:
I wanted to keep things separated and clean. Instead of keeping all fixtures in one file in one bundle you can move it to App/DataFixtures/ORM directory. However Symfony will not look for fixtures in this directory. You can:
add path to the fixtures in console command:
doctrine:fixtures:load --fixtures=/var/www/story/app/DataFixtures/ORM
create alias for above solution
override DoctrineFixturesBundle - how to do this
I hope this will help if you have similar issue.

Why creating model in any other location than client, meteor runtime throws exception?

I am a meteor newbie. I am trying out by building a simple app and it does nothing but shows list of items. I first tried out with hard coded model values in my client javascript code and it worked just fine. I then created a folder called 'model' under root of the application and created the model there like the following
Favorites = new Meteor.collection("favorites")
with this change, meteor throws exception pointing to this line of the file on load. If I move this code to client the code works ofcourse that is wrong. The full code is # https://github.com/ksunair/13favs It is a very simple solution has few files and less than 20 or 30 lines altogether. My client code is,
Template.favorites_main.helper({
favorites:Favorites
});
I did the following in order to clear your app of errors:
Favorites = new Meteor.Collection("favorites"); (Collection starts with a capital C)
I moved model/mainmodel.js to lib/mainmodel.js so Favorites would be available as soon as the template rendered. I always put my models under lib (or in a subdirectory) so they will be loaded first. This contradicts what I see in other places including discover meteor, so I'm unclear what the best practice is. In any case, it fixed the problem.
$ meteor add accounts-ui was needed because you referenced Accounts.ui.config.
You need to actually do a find in your favorites_main template. So it should look something like:
Template.favorites_main.helpers({
favorites: Favorites.find();
});

'The class exists in both dlls' .NET issue

I cannot deploy my asp.net 4.5 website because I am getting multiple dreaded "The type 'myClassX' exists in both C:\Users\Me\...\whereItsSupposedToBe\ and C:\Users\Me\AppData\Local\Temp\Temporary ASP.NET Files\root\1randomname\_shadow\2randomname\3randomname\App_web_myClassX.cs.4acf3bb.nommceoi.dll errors.
There are three files involved. MyClasses.cs contains definitions for MyClassB, MyClassC, MyClassD. Page1.aspx and page2.aspx include in their <%page %> tag a src attribute for MyClasses.cs.
I have so far done the following:
cleaned the solution and project
shut down VS12
deleted the root\1randomname directory and emptied the recycling bin
restarted the #^$#ing computer
deleted the offending files, cleaned and built, created new files and
renamed all involved filenames, classes and namespaces (oh yeah, they
all used to be'myOGClassA'....)
introduced dummy variables hoping that would change the dll
deleted the bin and obj directories
added the batch="false" attribute to the compilation element of the
web.config file as mentioned here: ASP.Net error: "The type 'foo' exists in both "temp1.dll" and "temp2.dll"
Something makes me wonder if having two of the aspx files having references to the same src file has something to do with it. But in all the blogs and SO posts Iv seen so far that would result in the conflicts both coming from the temp directories.
Head starting to hurt... Any suggestions?
I have "fixed the problem" but I am not sure why it is fixed.
To recreate the problem:
Create a New Project -> ASP.NET Web Forms Application.
Create a new folder ("Search").
Add the three files from the demo project zip found at Static-Site Search Engine with ASP.NET/C# by craigd (Searcharoo version 1). These files are Searcharoo.cs, SearcharooCrawler.aspx, and Searcharoo.aspx.
Take a look at SearcharooCrawler.aspx. At this point I get the 'exists...' errors. If you still do not see errors, view the project in the browser. The errors seem to appear as you are looking at the .aspx files in VS12.
To fix:
Create a new folder ("Happy_App")
Move Searcharoo.cs to the new Happy_App. This fixes the 'exists...' errors, but now Searcharoo.cs 'can't be found' so...
Delete the 'Src="Searcharoo.cs"' attribute from the top <%paging...%> tag in both aspx files. I believe that this Src attribute is no longer used in ASP.NET 4.5 (I may be wrong)
View in browser and navigate to the Search/SearcharooCrawler page. No errors! (need to add a few properties in web.config to get the searcharoo demo working, but thats not the point of this post...)
But the truly weird part - I found that after moving the Searcharoo.cs file to the Happy_App folder I could move it back the original Search folder without any 'Exists' problems!
Why??
If anyone has an explanation that would be awesome. But for now I'm happy I could get a resolution without sacrificing a small animal...

Web Resource was not found

I've spent the last day trying to get a checkbox validator to work. I found some starting code on the 4GuysFromRolla website, however this was coded back in 2006 and doesn't play alongside updatepanels.
I've made changes and now it works. As I'd made quite a few changes I wanted to standardise it and use it alongside other utility classes, so I created a new class project and copied the code verbatim.
The problem is that the original works, but I get a WebResource not found error on my new class project.
The differences are: The original was a web application project:
my new project is simply a class library project.
The original assembly and namespace have changed.
Both contain a single class and a resource file (.js)
Both resource files are contained in the root directory
Both resource files are set to embed resource
I'm running out of ideas, and have exhausted the answers I've found on the web with no success.
Is there an issue with the fact that its a class library? Have I perhaps overlooked something else?
Its pretty difficult to see beyond those 2 questions because the project is so small and insignificant.
Here's the code that does work:
if (this.RenderUplevel && this.Page != null)
{
ScriptManager.RegisterClientScriptResource(Page, this.GetType(), "skmValidators.skmValidators.js");
}
Here's the code that doesn't:
if (this.RenderUplevel && Page != null)
{
ScriptManager.RegisterClientScriptResource(Page, this.GetType(), "ValidationExtender.EvaluationFunctions.js");
}
Anyone give any ideas?
Thanks in advance.
The error turned out to be a mismatch between the dll's in the test page.

How to work with hook_nodeapi after image thumbnail creation with ImageCache

A bit of a followup from a previous question.
As I mentioned in that question, my overall goal is to call a Ruby script after ImageCache does its magic with generating thumbnails and whatnot.
Sebi's suggestion from this question involved using hook_nodeapi.
Sadly, my Drupal knowledge of creating modules and/or hacking into existing modules is pretty limited.
So, for this question:
Should I create my own module or attempt to modify the ImageCache module?
How do I go about getting the generated thumbnail path (from ImageCache) to pass into my Ruby script?
edit
I found this question searching through SO...
Is it possible to do something similar in the _imagecache_cache function that would do what I want?
ie
function _imagecache_cache($presetname, $path) {
...
...
// check if deriv exists... (file was created between apaches request handler and reaching this code)
// otherwise try to create the derivative.
if (file_exists($dst) || imagecache_build_derivative($preset['actions'], $src, $dst)) {
imagecache_transfer($dst);
// call ruby script here
call('MY RUBY SCRIPT');
}
Don't hack into imagecache, remember every time you hack core/contrib modules god kills a kitten ;)
You should create a module that invokes hook_nodeapi, look at the api documentation to find the correct entry point for your script, nodeapi works on various different levels of the node process so you have to pick the correct one for you (it should become clear when you check the link out) http://api.drupal.org/api/function/hook_nodeapi
You won't be able to call the function you've shown because it is private so you'll have to find another route.
You could try and build the path up manually, you should be able to pull out the filename of the uploaded file and then append it to the directory structure, ugly but it should work. e.g.
If the uploaded file is called test123.jpg then it should be in /files/imagecache/thumbnails/test123/jpg (or something similar).
Hope it helps.

Resources